While the headphones are plugged in go into "Control Panel" and then "Sound".
On the "Playback" tab, click the headphones once (not double click) just to highlight them.
Now right click on them and choose to set them as the default.
This should set them to be the only option available when they are plugged in. And then when unplugged the speaker should work.