Windows attempts to auto detect any changes to the plugs in your sound card. That doesn’t work well with my sound card (X-Fi something) so the speakers keep falling in and out randomly.
The sound card drivers are located under the registry key:
Search for “EnableDynamicDevices” (located under GlobalSettings somewhere) and set it to 0 (zero).
Note: You may have multiple sound cards (and old drivers), so repeat search to find all occurences in ClassId branch described above.
I’m spent a few days in figuring this out so I hope it helps!
Edit: The sound card on my Lenovo W510 seemed really bad (on powerfull high pitched sounds it would “break through” and play music normally). I figured since the W510 had only 1 socket it was a combined speaker/mic. So I did above patch, rebooted and suddenly the card works as expected.
Edit 2: Michael L. pointed out changing “ForceDisableJD” to 1 helped him. Michael has shared his findings in a comment on this page.