Lots of new batteries (for mobile devices, MP3 players, etc) have connectors with 3 pins.
I would like to know what is the purpose of this and how should I use these three pins?  

They are usually marked as (+) plus, (-) minus, and T.

The third pin is usually for an internal temperature sensor, to ensure safety during charging. Cheap knock-off batteries sometimes have a dummy sensor that returns a "temp OK" value regardless of actual temperature.
Some higher-end batteries have internal intelligence for charge control and status monitoring, in which case the third pin is for communications.