To get your iPhone out of headphone mode, you can try a few troubleshooting tricks, including restarting your iPhone or cleaning its headphone jack.
DFU mode can help you recover your iPhone or iPad using a computer.