Mutually exclusive headphone and speaker


I have a device that has only one set of analog audio out signals that are amplified for headphone usage. I want to be able to use these signals to output to a set of speakers OR a headphone jack, but not both at the same time.

The headphone jack has a detect pin that goes high when a jack is plugged in.

I have found a simple amplifier circuit for amplifying a headphone signal for an 8 ohm speaker.

I have created a test circuit (image below) with the headphone jack and the amplified speaker circuit on the right and the output for the right channel of the audio on the left. My thinking was that when the detect signal goes high, the LM386 Vs pin would receive voltage from Vcc. Feel free to delete parts of my circuit that are bad.

Using the detect signal from the headphone jack, I would like help designing the circuit that fits the following truth table:
Detect | Speaker | Headphone
0 | 1 | X
1 | 0 | 1

If you know how to use 123D Circuit you can fork my circuit and pick up where I left off.

Turns out this isn’t as complicated as I thought because I (finally) found some information about the detect switch states:

"The switch is closed when headphones are absent. The switch opens when headphones are inserted."
Here is the (presumed) working photo: