The core difference
JPG is lossy — it compresses by discarding image data the eye is least likely to notice, achieving small files at a controlled quality cost. PNG is lossless — it compresses without throwing anything away, which keeps every pixel exact but produces much larger files for photographic content.
Where JPG wins
Photographs are JPG's ideal case: natural color gradients, complex textures, and lots of visual detail compress extremely well with minimal visible loss. A high-quality JPG of a photo can be a tenth the size of the same image saved as PNG, with no perceptible difference on a screen. This is why cameras, phones, and virtually every photo-sharing platform default to JPG.
Where PNG wins
Anything with sharp edges, flat color fields, or text — screenshots, logos, icons, diagrams — compresses poorly in JPG, which tends to introduce fuzzy 'ringing' artifacts around hard edges. PNG handles these perfectly since it doesn't discard any data, and it's the only common format offering true transparency, essential for logos and graphics meant to sit over other content.
A simple test
Ask one question: does this image need to sit on top of something else, or show through to a background? If yes, it needs transparency, so it must be PNG. If no — it's a photo or will be placed on a solid background — JPG is almost always the better choice for size and universal compatibility.
What about file size limits?
If a form or website has a strict file size cap and you're trying to upload a PNG that won't fit, converting it to JPG first (assuming you don't need transparency) is usually the fastest fix — PNG's lossless nature means it can't shrink nearly as far as JPG can before hitting the same limit.