Sooner or later headphone plugs break from so much bending and/or keeping them in your pocket. The problem is usually the copper inside breaking from so much stress. Before buying a new pair of headphones or buying one of these ugly generic plugs try removing the old plastic cover, cutting the broken cable and re-soldering to the jack (copper color cables to the outside upper section, red cable to the middle and green to the core section). Although the copper is usually covered with some sort of plastic paint (internal isolation) and warped with a fiber (tension protection?) the soldering iron melts that all away. Sound quality not apparently affected. Of course check the connection before putting the epoxy! The heat-shrink tube helps reducing bending stress at the interface of the epoxy-cable. The longer the tube the better. Make sure the epoxy covers the end of the tube to fully fix it. Clear epoxy just gives it a nicer look and let you check that the soldering points are still there.
Also posted on Reddit: Fix your headphone