I am going to be wiring up a custom circuit. Audio is output from two LR audio cables. I am going to wire them up to two mini speakers, one for each LR cord. But how do I add in a part to detect if headphones are plugged in so instead of playing audio from the speakers it would play to the headphones that were plugged in?
Headphone jack sockets include switched contacts for exactly this purpose. See this schematic of a headphone socket:
So you would connect your source to pins 2 & 3, and your speakers to pins 4 and 5. As soon as the headphone is plugged in the speakers are disconnected.