Setting/app to route audio input to phone's mic while a wired headset is connected to it
There is no system-wide setting for this, unfortunately. And apps that try to control audio routing are usually hacks that cause problems on their own.

But I have a hardware solution for you -- buy one of those splitter adaptors that convert 4-pin TRRS into 2 3-pin TRS, separating for headphones and microphone, and only plug the headphones jack into your phone. Look for something like this: https://www.amazon.com/StarTech-MUYHSFMM-Headset-Splitter-Adapter/dp/B0058DOWH6 (I'm not recommending this particular adapter, just showing how it should look like).