github(dot)com/milgra/airpodssoundqualityfixer/releases/tag/1.0
This app automatically changes the microphone input to the built-in Mic. Works like a charm with my Airpods. Should work with other headphones.
I would also tinker with the new Shortcuts for Mac to natively automate it