this is the problem with the headphones 50% times . bit try disabling ok Google detection on wired headphones . and try resetting your device, if that doesn't work its a hardware problem fix it on Samsung warranty if u have or go to a shop ( try installing a genuine headphone jack for the original hardware) and try installing the latest version of android . a custom rom can also cause this problem but in my opinion the headphone is the problem try using a split headphone connection