The short answer
Use JPG for normal photos and broad upload compatibility. Use PNG for transparency, screenshots, logos, graphics with text, and images that need crisp edges.
File size and compatibility
JPG is usually smaller for photos and accepted by more forms. PNG can be larger, but it handles transparency and sharp graphics better.
Common mistake
Do not convert a transparent PNG to JPG unless you are okay with losing transparency. JPG does not support transparent backgrounds.