Extension cord would have been a lot easier.
Some headphone chords have different construction. If each wire has jackets, consider yourself lucky. If one wire is wrap around the other wire, you might as well replace the whole cord all the way to the speakers.
The wire on wire uses a special coating to isolate the wire getting contact to each other, therefore you will need to scratch the shielding to join your extension wire, you will also need a soldering iron to get it connected properly and the worst part is that sometimes these wires are very thin, burning the wire before you can even solder them together is common none experienced.
If the wires are separated with jackets then strip the jackets exposing enough wire so you can join your extension. Use of soldering iron is also necessary; heat shrink tube is the best way to insolate the wires from each other than an electrical tape.
Green wire usually ground.
Black and/or an exposed wire are ground.
Red goes to the center or the middle ring of the terminal plug.
White goes to the tip of the terminal jack.
PS. If you post a picture, I would be able to tell you which way to start.