Does your Mac detect your earphone when it's plugged in?
Amazingly, my Mac Pro doesn't detect it automatically. Because of that, I have to constantly fire up my System Preferences to change my audio output settings.
If you have similar problems, you might want to check out SoundSource. After installing that, I no longer has the hassle of using the System Preferences. This is pretty amazing. I thought Apple would have figured this one out.
SoundSource download page