You can try to remove the headphone jack from the iPhone and then plug it back in. If you are still stuck, you may need to reset your phone by holding down both the power button and the home button for 10 seconds.