Check whether the headphone connector is plugged in the bottom.
1. Confirm whether the headset is inserted all the way, re-plug and unplug the headset and try to rotate the headphone jack.
2. Enter the settings of Gesture Motion Sense Communication Motion Sense - turn off the hands-free switching option.
3. After backing up important data, restore the phone to factory settings.
4. Confirm whether the headphones are original. If conditions permit, you can replace them with other headphones for listening and troubleshooting.