There are two ways to correct a bad headphone connection. The first thing to try is to clean the connector. To do this, take a que-tip with a small amount of rubbing alcohol on the tip, and swab the connector. Do this and on the jack and the connector being careful to dry it afterwords. Check the connection after this to see if it did the trick.
If that doesn't work, you might need to replace the connector entirely. Chris Metcalf details how to take headphones that have a bad connector (headphone plug) and repair it by replacing the plug entirely. Lots of pictures and a great amount of how-to detail.
Another example of this type of headphone plug repair can be found at
ZuneMods