I have a motherboard with on-board sound that can be configured for playing different sources to speakers and headphones. Your motherboard or sound card may already have this option.
If not, I don't think software would be able to provide it, as it seems like a feature that would need to be...