People ask me this more than almost anything else, and the honest answer is "it depends on what's actually in the image," which I know isn't a very satisfying thing to hear. So here's the fast version first, then why.
The ten-second version
Photo with lots of color and soft gradients? JPEG or WebP. Screenshot, logo, chart, anything with flat colors and hard edges? PNG. Need transparency? PNG, or WebP, which also handles it. Building for the modern web and don't need to support ancient browsers? WebP, for almost everything.
Why JPEG is still around
JPEG uses lossy compression — it throws away information the eye is unlikely to notice, subtle color shifts, high-frequency detail, to shrink the file dramatically. For photographs this trade works beautifully, because that's exactly the kind of detail cameras capture in excess anyway. The downside shows up on sharp edges and text, where JPEG tends to introduce a slight blur or ringing. That's why a JPEG screenshot of text often looks faintly fuzzy up close, even at a high quality setting.
Why PNG is wrong for photos, and right for everything else
PNG is lossless, it keeps every pixel exactly as it was, which means file sizes balloon fast on anything photographic with gradual color variation. But for a screenshot, a three-color logo, or a diagram, PNG's compression does really well, often beating JPEG at the same visual result simply because there's less "noise" for it to have to store.
Using PNG for a vacation photo always reminds me of shipping something in a safe when a padded envelope would've done fine. Technically it works. You're just paying for protection you didn't need.
WebP, the one I'd default to
WebP supports both lossy and lossless modes, plus transparency, in one format, and at equivalent visual quality it typically comes out 25–35% smaller than JPEG. Browser support has been solid for years now (every major browser handles it fine), so unless you're exporting for some old piece of software that's never heard of it, WebP is usually the better default these days.
A test worth running yourself
Take one photo, export it three ways at roughly matching visual quality. A typical result: PNG around 2.4 MB, JPEG around 340 KB, WebP around 260 KB, and all three look nearly identical on a normal screen. That gap is basically the whole argument, condensed into one example.
PNG still earns its keep when you genuinely need transparency — a product photo cut out for a listing, say. JPEG can't do transparency at all, so in that one case PNG (or WebP with alpha) is the only real option.
ImgReduce lets you switch between all three formats from the same panel, so you can compare file sizes on your own photo before deciding — give it a try here.