Hi
With your iPhone stuck in headphone mode, Apple advises that you should contact Apple Support (mail-in service may be available, if required), make a Genius Bar reservation or visit an Apple Authorised Service Provider for assistance:
If your headphones don't work with your iPhone, iPad, or iPod touch - Apple Support