Actually a power type jack like the arduino uses for it's external power input will perform what you are asking for. If you look closely at such a jack you will notice it has one center pin solder connection and two 'ground' solder connection. One of those ground connections wire to the devices ground circuit, the other would wire to the speakers ground connection. When a plug is inserted the hot center and a ground is avalible for the external line-out device you want to have the audio signal. At the same time inserting the plug caused the speaker ground contact to open up and removed from the internal circuit ground, thus the speaker gets no signal.
That makes sense?
Lefty