JPEG was designed for photographs and PNG for graphics with sharp edges. Most format confusion disappears once you know which of those two things you are saving.
Converting between them is not symmetric: JPEG to PNG preserves what survived compression, while PNG to JPEG discards detail permanently.
Photographs
A camera photo has smooth gradients and fine noise. JPEG’s frequency-domain compression handles that efficiently; PNG stores the same picture several times larger with no visible gain. For photos, JPEG at quality 80–90 is the right default.
Screenshots, diagrams and text
Hard edges and flat colour are exactly what JPEG handles badly: you get halos and ringing around every letter. PNG keeps them crisp and often produces a smaller file for this kind of content.
Transparency
JPEG has no alpha channel. If a graphic needs transparency, PNG (or WebP) is the only option of the two; exporting a transparent PNG to JPEG fills the background with a colour you choose.
Editing and archiving
Every JPEG save loses a little more. If an image will be edited repeatedly, keep a PNG or the original file and export a JPEG only for delivery.
Frequently asked questions
No. It preserves the current pixels losslessly; detail already discarded by JPEG is gone.
PNG stores every pixel exactly. JPEG had already thrown away detail the eye barely notices, which is why it was smaller.
PNG, because logos have flat colour, sharp edges and often transparency.
JPEG for photos, because attachments have size limits and PNG will be larger.