JPEG - photographs
JPEG is lossy and tuned specifically for the kind of gradual tonal variation that photographs contain. For a camera image it produces dramatically smaller files than PNG at quality most viewers cannot distinguish.
Its weaknesses are sharp edges and flat colour: text, logos and screenshots develop visible fuzzy artefacts around hard boundaries. It also has no transparency at all.
PNG - graphics, text and transparency
PNG is lossless and supports a full alpha channel. Logos, screenshots, diagrams, anything with crisp text or a transparent background belongs here.
Used on a photograph it is simply the wrong tool: lossless compression has very little redundancy to exploit in camera noise, so the file stays enormous.
WebP - the modern compromise
WebP does both jobs. Lossy WebP is typically 25–35% smaller than a JPEG of comparable quality; lossless WebP is usually smaller than the equivalent PNG, and it supports transparency in both modes.
Browser support is now effectively universal, so for images on your own website WebP is close to a free win. The caveat is elsewhere: some upload forms, older desktop software and a few social platforms still prefer JPEG or PNG.
The transparency trap when converting
Converting a transparent PNG to JPEG has to do something with the transparent pixels, because JPEG cannot store them. Most tools fill them with black, which is rarely what you wanted.
Flatten deliberately onto the background colour you actually intend before converting, rather than discovering the result after upload.
The short version
Photo going anywhere: JPEG. Logo, screenshot or anything transparent: PNG. Image on your own site: WebP. Never save a photograph as PNG.