check for dust or fluff or anything that could be in the audio socket. Most high-end audio sockets have some sort of mechanism inside that tells the OS to switch to headphones when you plug something in, if there's dirt in there, it'll jump between the two.
I've had it on both a Linux laptop and on an old MacBook Pro