Maybe an A/B box?
It's a switch box that connects one input and lets you flip a switch to choose between two outputs (it can also be used the other way around). It's like a KVM, but for audio.
Connect the A/B box to the back of your sound card. Get another wire to connect the box to your speakers. The headphones would also go to the box. You'd just flip the switch when you want to change between headphones and speakers.
If you don't care about auto-muting speakers when headphones are plugged in, then any headphone splitter would do the job.