You want jack "C" at the bottom of this link: http://en.wikipedia.org/wiki/Phone_connector_%28audio%29
The tip and sleeve switches are electrically isolated from the plug so signal is transmitted uninterrupted.
There are 1/4" jacks here (http://www.minute-man.com/acatalog/1_4__Stereo_Jacks.html) that do this. I'm sure they have 1/8" jacks that do the same thing, but I didn't look.
I was looking for the same thing, but for switching inputs based on whether the plug was inserted in the effects return on a tube guitar amp. Can't be puttin' that signal level into the common when someone has it in their hands!
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.
Best Answer
The LM4863 is a dual amp with headphone functionality. Its datasheet shows exactly how to connect speakers and a headphone jack to implement the application you describe.