Me too! So sick of this issue. This has been the most frustrating problem that has existed for years, across multiple versions of iOS. All is required is for ios to Not automatically switch audio output when connected to a new device, or, to prompt a user when a new device is connected. This is some very basic UI and I don't understands why it has continued to not be addressed. It's not even possible to implement such a prompt via shortcuts or automations.
Suggestion to 'forget' the bluetooth device is a poor workaround, and even more frustrating with cars where it is not always a quick/simple process to re-pair. And it should not be necessary!
The suggestion from Ali for call audio routing is not an appropriate fix, and just an attempt at a shortcut. It sometimes helps with phone calls but does not help with music or listening to anything else. I've also tried tagging the bluetooth device as "speaker" or "headphone" etc, but it makes no difference.
I still have this issue daily with my phone automatically switching to a bluetooth speaker, or a car when it is turned on, regardless of what I am doing or listening to / talking to.
At least with airpods I can click the airpods and the audio switches back, but why did it switch in the first place? Horrific and infuriating design.