Whenever I remove my headphone, my MacBook pro mid 2012 (macOS Mojave, 10.14.5) defaults to "Digital Out — Optical digital-out port" (and the port is usually "red" -digital out light), but sometimes it doesn't show it [usually when sound is not playing]) which is not OK since it should be "Internal Speakers — Built-in".
I've tried these terminal commands and they don't work.
sudo pkill coreaudiod sudo killall coreaudiod
Are there similar commands to redirect the automatic "Digital Out" setting?
The only fix I found so far for that bug, is to blow air inside the jack for ~5-10 seconds and then I have access to my speakers again... weird.