GIF supports a palette of 256 while JPG supports 16 million, therefore JPG is the better choice when you're working with photos and images with lots of shading and variation.
GIF is better for line drawings and logos, and is what you use for animated graphics or graphics with some transparency.
PNG is like GIF except you can control the transparency, the images are often compressed more, but PNG doesn't support animation. Further, last time I heard not all browsers support it.