Have you given Audio Switcher
a go? I use it to auto-switch between optical and analogue speakers, with a manual key press. It can be automated too based on input jack detection.
It will set sample rates and formats too, if you so wish.
Mega Beast - Intel i7 4790K | Gigabyte Z97X-UD3H-BK | 32GB DDR3 | SLI GTX 1070 | Samsung 850 Evo 1TB
Mini Beast - Intel C2E QX9770 | Gigabyte X48T-DQ6 | 16GB DDR3 | KFA2 LP GTX 750Ti | Seagate 2TB SSHD