How can I determine which wire is which when putting a new plug on an extension cord?
They make a tool called a continuity tester. These also come in the form of a meter product that can also measure voltage and current. You can pick these up at most auto parts stores or hardware stores for a relatively low price. 



To use the continuity tester, you would connect the clip to one of the known wires, and then touch the end of the probe to each of the unknown wires in turn. Which ever wire lets the bulb light up is the same wire as the known wire. Obviously make sure everything is unplugged from mains power before doing this.



To use a multimeter for continuity testing you make sure that the cord/wiring that you are testing is not connected to any mains outlets. Then make sure the two test leads are plugged into the black COM jack and the red VOLT/OHM jack. Rotate the range selector to the lowest OHMs setting. Momentarily tough the two test lead ends together to verify the meter is working correctly. The meter should show a reading of near zero ohms. In the case of a meter like shown above a zero ohm reading will deflect the needle all the way to the right. Next step is to touch one of the test leads to one of the known wires. Then at the same time touch the other test lead to the unknown wire ends in turn. The one that causes the meter to show a reading near zero ohms (deflects the needle to the right) will be the same wire as the known wire.