What about after taking the picture and the photo is on a computer? If any changes have been made to the image, even if it's just to crop it or remove some red-eye, ALWAYS re-save the image as a TIFF (one layer) or Photoshop (multiple layers) file. It is strongly recommended to NOT re-save any image as a JPEG!
In order to e-mail a file or upload it to online tools the web, then and only then should the TIFF or Photoshop file be opened and re-saved as a JPEG. If it needs to be resized for the intended use, that should be done first, and then the image can be re-saved in JPEG format. (Most cameras create files much larger than needed for posting or e-mailing.) A quality setting between 5 and 8 is suitable for most uses. (Most programs will provide a slider to choose the quality when saving an image as a JPEG.) If resaving a Photoshop file as a JPEG, flatten it (reduce it to one layer) first. Just be sure to not write over the layered Photoshop file.