You can't do a switch like you are proposing. Your applications have already opened up a handle to a buffer which is being read by a specific sound card driver. The reason for this goes beyond simple laziness. Different sound cards support entirely different features, and your application needs to account for those different features. Mainly, possible sample rates, bit depths, and mixer control if applicable.
Now, regarding mapping applications to a specific output... this is application specific. For example, Winamp's output plugins support choosing specific sound device. You could set Winamp to play your music out of your primary sound card hooked to your speakers, and set your default sound card to whatever your headphones are plugged into, so your games will automatically play out of them.
Finally, if you expect to get different outputs out of your sound card for your headphone jack vs. the speaker jack, don't. Your sound card drives these with the same output. Depending on your sound card, you might be able to use your surround sound outs as a separate output, this is device specific.