If I edit an image file using some application like Gimp, Photoshop or MSPaint, while saving I will be asked to select the required file-format. There are different formats available, the common ones are jpg, png and bmp. Other less common options are gif and tiff.
So which option should I select? What are the merits and demerits of using a particular file format?
In general, I would say you probably want to save to a format that supports metadata unless you have a compelling reason to do otherwise. In that regard, jpeg and tiff are the two most common formats for photography outside of RAW+XMP or DNG.
I have used PNG in some of my online portfolios, as I've taken to rounding the corners of my scaled-down images for nicer exhibition and to do something to set my work apart from everyone elses. The down side of this is that PNG does not support metadata. This has limited me in a lot of respects, as most of the better online photo sites support automatic metadata extraction and display (i.e. Flickr).
To be more explicit...when exhibiting downscaled versions of your art online, such as on Flickr, DeviantArt, 1x, RedBubble, etc...it is probably best to use JPEG as your final output format. These files are good quality but very compact, and do support metadata. For long-term storage of originals, I would recommend RAW+XMP, DNG, or TIFF, as all of those formats do lossless compression and also keep metadata. TIFF might be the best choice for you if you are using Gimp. I have used RAW+XMP myself, as I like having my original raw files...but I have also considered converting everything to DNG to simplify file management.
JPEG is lossy, which means it compresses the image (in part) by discarding data. The data it discards is (normally) chosen to minimize the affect on the quality of the image, but it (virtually) always loses at least a little quality -- and depending on the quality level you choose, it can lose quite a bit. For most photographs it should be considered a display-only format -- once you've converted something to JPEG, you don't want to do any more editing on it. If you need to make changes, you re-start from some other format, make the changes, and do another JPEG conversion.
GIF uses only lossless compression, but is limited to 8-bit (256) colors, which is quite limiting for photographs.
PNG was designed as a replacement for GIF, and mostly succeeds. It supports 24-bit color (8 bits each for red, green, and blue) and uses lossless compression.
TIFF is really a container format that allows you to insert various kinds of data into the container. While it's used primarily for images, it's really almost like a file system, so you could theoretically use it for almost any kind of data. This has a couple of consequences. One is that even if a program supports TIFF files, it may not support all TIFF files -- e.g., many don't support LZW-compressed images. In fact, few programs support all possible TIFF files. Another consequence is that TIFF tends to have a fair amount of overhead, and writing code to support TIFF (at all well) is a pain (which is why so many programs support it only incompletely).
BMP is basically just a Windows device independent bitmap written out to disk. It has only extremely limited support for compression (and most BMPs aren't compressed at all). Programs written for Windows can read/write BMP really easily, but there's not much else to recommend it (in particular, BMP files tend to be quite large for the amount of data being stored).
Conclusion: JPEG is useful as an output format (e.g., to display things on web pages it's good because it's compact, and virtually everybody can read it).
As an intermediate format that you might use (for example) to store a file that might later be edited, TIFF is about the only one of these that's really of much use.
The others (GIF, PNG, BMP) aren't really of much use for photographs.
If using Photoshop or Gimp save as PSD file.
Save to JPG in order to upload photos to the web.
I save my edited images as TIFF with LZW compression. I use the Gimp to edit and I have scripts based on ImageMagick that convert the TIFFs to JPGs of various sizes and quality levels for web use, printing, etc. I expect PNG would also work; I chose between them choice several years ago and I've forgotten why I picked TIFF. (Maybe it was the metadata issue other responders have mentioned, or perhaps ufraw's PNG output was too slow.)
When I want to preserve layers for future editing, I save as .xcf.gz (Gimp's native format with gzip compression). Of course, if you use programs besides Gimp, that may not be helpful.