At first, I too had got a little frustated. More because of the fact that these are premium devices on which people trust but since machines are machines.
So first of all, do not get dejected. You’ll yourself fix this up. Just the time may vary. Its not as complicated as it seems. My personal device has got appreciable amount of debris inside the jack which is normal but then too I tried this simple procedure.
Step 1: Turning on airplane mode wont help all the time so plugg-in the same headphones that causesd this issue and play a song.
Step 2: Listen for 20 seconds.
Step 3: While listening double tap the home button to check if it says headphones connected.
Step 4: Simply pull-off the headphones.
Step 5: Magic! You start to hear the speakers and realise your heart beat is normal. Enjoy...