I completely freaked out when this happened with me.
A reboot definitely fixed it for me but rebooting it every time you face this issue is annoying.
Though i have no permanent solution for this i think if we try to pull out the earphone's a very little bit out of the jack at one perticular...