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!
Is it possible to use the power from the headphone jack line out to
amplify the signal in order to get the speaker to be louder?
Here's the thing: The power in the headphone jack is in the audio itself. The power in a normal wall outlet is 50/60Hz AC. The power in a headphone jack is also AC and in the frequencies that you want for your audio! There is no additional power contained in a headphone jack other than the audio itself.
So, if you could somehow convert the power in the headphone jack into something useful and convert it back into a form for driving a speaker, and could do it with 100% efficiency then you would end up with exactly what came out of the headphone jack in the first place.
In short: You can't amplify the power without another source of power. But all is not lost!
What you really want is louder audio, and a way to do that is to make your speaker more efficient. Speaker efficiency is usually expressed as "sensitivity" and is specified as XX dB at 1 meter at 1 watt. A normal speaker is 75 to 90 dB (@ 1 meter @ 1 watt). It might not look like it, but 75-90 dB is a huge range! You can simply get or build a speaker with better efficiency.
Another thing that effects efficiency is the speaker enclosure itself, and the type of speaker. Look into horn speakers. There are horn speakers that have sensitivities up to 105 dB (@1m@1w). Although these will likely be too large for your application, it might be interesting anyway.
Driving an 8 ohm speaker with a headphone jack is questionable. Some devices will do this just fine. Some devices might distort but otherwise be fine. And other devices might be permanently damaged. Unfortunately there is no good way to find out without just trying it.
In theory you could make an impedance matching transformer that would show a proper load to the headphone amplifier, but who's output is good enough to drive an 8 ohm speaker. Just keep in mind that a transformer will not increase the power, only convert the form of that power so different devices can play nice together. I have not seen such a transformer for sale, but I also have not looked for one. But in theory you could make one.
Given all the different issues, if it were me I would figure out a way to make a small battery pack with an amplifier in it. Yes, it's bigger than what you want. But it will probably be the best compromise between volume, size, cost, and robustness.
Best Answer
This kind of jack allows left and right speakers to be connected when no headphone plug is inserted (top image).
Upon inserting a headphone plug, both speakers are disconnected by mechanical force of the plug forcing both switch contacts to open. Output current is directed only to headphones, allowing private listening to the headphones only (bottom image).