How can one pair of headphones be connected to two audio sources?
There are a few methods:  

A simple passive resistive mixer is basic, but a bad solution for a couple of reasons:



One is that in order to keep a low impedance output you need to use low value resistors and this loads each output excessively, plus creates a voltage divider between the outputs.
Each output in the above example would see a 150 ohm load (e.g. the leftmost output will see R1 || (R2 + R3))  

So we can buffer the signal:



This solves the loading issue (now each output sees 3.3k which isn't as bad), but not the voltage dividing issue. Say we have 3 inputs of 1V pk-pk. With all three plugged in, the contribution of each output will be a maximum of 333mV. This is okay (as we can add a gain of 3 to the opamp to compensate), as long as we don't unplug one of the signals.
If we unplug one of the signals, we change the loading on the other two and the voltage divider changes. The signal voltage from each will now be 500mV. If we unplug another then the full 1V pk-pk will be output.
So the output level of each channel is greatly affected by change of the other inputs - not just unplugging, imagine using volume controls.   

A solution to this problem is the active inverting opamp mixer:



This is a current amplifier, and uses a virtual ground at the summing point to prevent any interaction between the channels. The feedback resistor R1, matches the sum of the currents flowing through R3, R5, and R6 (in order to keep the inverting input at 0V)
This means that the output voltage is simply (I(R3) + I(R5) + I(R6)) * R1.
If we remove an input, the voltage contribution from the other inputs stays the same.
So this is the best simple mixing circuit out of the three shown.    

Try simulating the above circuits in SPICE to get a feel for what's going on.

The ESP pages linked to by Shimofuri are an excellent source of such information.