My Mac switches to speaker after locking the screen When listening to music, after locking my MacBook Pro (ControlShiftPWR) and leaving, when I come back after 5 mins, I can hear the sound from the external speakers and nothing from my headphones. I have to unplug and replug to get it back to normal.

Anyone experienced this behaviour before? I'm running Sierra 10.12.1.
Yes, make sure that under System Preferences -> Sound that the default device (Headphones) is selected. After setting this, my Mac was remembering that I was using headphones after unlocking the screen.