This happened to me yesterday and I was confused for a minute since it has never happened to me before either. I tried numerous methods and tricks to get it fixed and finally I did manage to fix it. I've also written a quick step-by-step guide on how to fix an iPhone from being stuck on Headphones mode to help others who face such similar situation.
Here's an excerpt from the guide:
13 Simple Ways to Fix iPhone Stuck in Headphones Mode - Saint
1. Try removing your iPhone’s case
Make sure that you remove your iPhone's case and check if that does the trick.
Most of the time, it could just be that your iPhone's case could be blocking the pathway to the audio jack, which then causes your iphone to remain stuck in Headphones mode.
2. Turn your iPhone off and back on again
Even if you find that you remove your iPhone's case and it still remains stuck in Headphones mode, then what you can do is turn your iPhone off and back on again to make sure that the problem does not lie in your software.
3. Plug in and out your headphones a few times
Try plugging in your headphones and out a few more times, as sometimes your iOS can forget that your headphones were disconnected. One thing you should make sure when you plug in, is you should be able to hear the audio clearly on your headphones.
Once you are pretty sure it works all great, only then should you slowly stop the audio, clear your history (by double tapping your home button and make sure no background apps are running) and then firmly plug out your headphones.
4. Try Another Pair of Headphones.
Different headphones have different configurations.
So if you do have the original Apple's EarPods (and I really mean the originals, not the fakes) then go ahead and give that a go. Whichever brand of headphones you're using, certain types or brands may not go well with your iPhone.
It's completely fine if you do not have the original Apple EarPods, any of the headphones would do, however, as long as it is compatible.
5. Go AirPlane Mode
Step 1: Go onto your iPhone and then swipe up from the bottom of your Home screen to open your Control Center.
Step 2: Then tap Airplane Mode.
5. Use a Bluetooth speaker
You see, if you're stuck on headphones mode as a result of your plug in headphones or ear pods then you can easily undo it if you use a Bluetooth speaker or headphones as they work without the need to plug in them (in short, they're wireless)
So when you connect your iPhone to a Bluetooth speaker or headphones, your iPhone will recognize the Bluetooth device and will also know when you disconnect it (since you're not unplugging it manually which can sometimes be confusing to your iPhone).
This is a pretty neat trick you can do and all you will only need is either a Bluetooth speaker or Bluetooth headphones that you have lying around.
6. Look inside your iPhone
Go ahead and grab your torchlight.
Then use it to take a look inside your headphone jack, and look for whether if there is any dirt stuck inside it, as this might be what's causing your iPhone to be stuck in headphones mode. 🙂
If there is dirt then …
7. Clean inside your iPhone’s Headphone jack
Cotton Buds
You have cotton buds lying around right? I'm sure you do.
Grab one and use it to clean inside your headphone jack gently.
Since they're soft you don't really have to worry about it being harmful.
The BIC Pen
Ahh the BIC Pen..
This is a pretty neat trick and it works well to grab all that debris that might be found in your Headphone jack.
Here’s how you can use a BIC pen to remove debris from inside your iPhone’s headphone jack.
Step 1: Grab any standard BIC pens that you have lying around, and remove the cap.
Step 2: Now try and pull the pen tip from its plastic casing. It will be much easier if you use pliers to pull it.
The tip is the one that you use to write with, attached to a circular plastic cartridge that contains the ink.
Step 3: You're doing great! Now all you will need is the opposite end of the cartridge as it is the perfect size to remove all the annoying debris from inside your iPhone's headphone jack.
Step 4: Just go ahead and insert the end into your iPhone's headphone jack and gently twist it to loosen the debris, then once you're done just shake it out of your iPhone.
That's it! 🙂
8. Update your iOS
9. Change your iPhone's Settings
Step 1: Head over to your Settings, and then General.
Step 2: Next select Accessibility
Step 3: Scroll down until you see Interaction
Step 4: Keep Scrolling, until you see Call Audio Routing
Step 5: Sweet! Now all you have to do is just make sure it is set to Automatic, if yours is not then choose Automatic from the list.
Now if you already find that it is already set to Automatic and it is still not working, then try and test by setting it to Speaker.
To check if this did the trick, all you have to do is just place a call or a Facetime audio call, and then see for yourself if your speaker works.
If it does, then just go back to this same setting and change it back to Automatic. 🙂
10. Put your iPhone in DFU mode
This is the deepest type of restore that you can do on an iPhone.
When you DFU restore your iPhone, there's always the potential for something to go wrong because it is not like your regular restore method where you just tap one button to have it reset back to how it was when you first got it.
It restores the very code that makes up the software of your iPhone. It's complicated to explain but that's the most simplest way to put it.
Read more at Saint