If it thinks there is a headphone jack still inside this means that the headphone jack is clogged, water damaged or just has gone plain faulty.
You can try cleaning the headphone jack first and if that does not work then you will need to replace the charging port dock assembly.
I tried cleaning it for a few clients. All ended up still not solving the issue so I ended up replacing the charging port dock assembly for them.
You can get the part from here:
iPhone 6 Lightning Connector and Headphone Jack
iPhone 6 Lightning 接口组更换