The quick answer
Use JPG for photographs, PNG for graphics with sharp edges or transparency (logos, icons, screenshots), and WebP when you want the smallest file for the web and your audience uses modern browsers. Most images fit cleanly into one of these three.
JPG
JPG is lossy and excellent for photos: it throws away detail the eye barely notices to make small files. It does not support transparency, and repeatedly editing and re-saving degrades quality. Best for photographs, email attachments, and anywhere wide support matters.
PNG
PNG is lossless and supports transparency, so lines and text stay perfectly sharp. The trade-off is size: a photo saved as PNG is much larger than the same photo as JPG. Best for logos, icons, diagrams, and screenshots — not big photographs.
WebP
WebP is a modern format that usually beats both: smaller than JPG at similar quality, with support for transparency like PNG. It is ideal for websites. The main caveat is that some older software still cannot open it, so for maximum compatibility you may convert WebP back to JPG.
Converting between them
Pick the format that matches the job and convert as needed: PNG to JPG to shrink a photographic graphic, JPG to WebP to speed up a website, or WebP to JPG when something cannot open a WebP. Conversion is quick and can run entirely in your browser.