Help with audio switching? win 7

I've been browsing around the web looking for an answer, but none have come up that fit my problem.

I have a 5.1 sound system on my pc, but when I game at night, I have to use my headphones. Is there some way I could set it up so that when the headphones are plugged into the front jack, the audio switches from 5.1 to stereo? (They both register as the same audio device)

so the audio plays through both? or just the 5.1 system?

The audio plays through the 5.1speakers when headphones are unplugged, but play through the headphones when they are plugged in.

BUT when the headphones are plugged in and the audio config is still set to 5.1, the channels are missing i.e. when I look directly at someone in a game, I don't hear them(since it's the center channel), but when I turn left or right, I can hear them(side channels are the only ones working in the stereo headphones set to 5.1). So I would like it if the configs could switch to stereo when I plug in the headphones and back to 5.1 when I plug them out.