Your question is pretty broad so I will try to answer it as best as I can.
The main thing you are looking when optimizing a JPEG (or JPG, it's the same thing) is a balance between quality and file size. Period. This is either if youre going to print or to the web.
Optimizing a JPG is strictly an "eye balling" process. It's pretty much an "art" to optimize a JPG, albeit, an art easy to learn.
To best optimize a JPG image for web, there are a few things we should consider:
- What are the actual dimensions the image is going to be used at? If the image is small, maybe JPG isn't the best format, maybe a 256-color PNG or GIF (not used much these days other than animations).
- Can parts of the image be blurred in order to reduce the file size when exporting the JPG? This what is called an "art directed" decision. For example, maybe we could blur the background of a close up photo of an insect or a person, this helps increase the focus on the main part of the image while reducing the file size.
- Maybe we could serve the same image to mobile and desktop devices? This is a pretty common scenario, albeit, some people can't help to frown upon it.
An online tool I use a lot to optimize JPGs and PNGs is https://tinypng.com/. All you need to do is drag and drop your file inside the dotted box and TinyPNG does the rest. Granted, you should already have the image sized at the right dimensions you're going to use it at, TinyPNG won't resize the image.
I hope this helps.
If you have any questions, don't hesitate to ask.