If you're thinking of trying to replace the 3.5mm plug on a cheap pair of headphones, it's probably not worth the hassle. But if you have invested in an expensive pair that is suddenly not working, you can try replacing the plug to see if that fixes the problem. Often the headphone wires will loosen from the plug over time, so soldering the wires to a new headphone plug may get your headphones back in working order. Be sure you know how to handle a soldering iron before attempting this process.
Cut off the existing 3.5mm plug where the base meets the headphone wires.
Strip the exterior of the headphone wires until about 1/2 inch of bare wire is accessible. You should see a green wire, a red wire, and two copper wires.
Keep the green and red wires apart. Twist the two copper wires together to make one copper wire. Light a match. Hold it to the end of each wire for one to two seconds.
Unscrew the metal portion of the new plug from the plastic case. Carefully thread the three wires through the base of the new plug so that your three wires are exposed at the other end of the plastic case.
Place the metal portion of the plug into the vice to hold it while soldering or tape the metal portion of the plug to the table to hold it steady. Solder the wires to the terminals at the base of the metal portion of the new plug. Solder the copper wires to the large, outside terminal. Solder the green wire to the middle terminal. Solder the red wire to the third terminal. Allow the soldering to cool.
Remove the metal portion of the plug from the vice. Screw the plug back together. Secure the base of the plug to the headphone wires with electrical tape, making sure that any exposed portion of wiring is completely covered by tape.
Do not hold the plug in one hand and solder with the other. The heat will travel through the plug and you will burn yourself. Test your new headphone plug on a piece of equipment you don't care very much about to make sure it is working properly before using it on your higher end audio equipment.