Automatic switching is clever until your AirPods leave the podcast on your phone for a video that started on another screen. You can turn that behaviour off.
Put the AirPods in, so they are connected, and open Settings on the iPhone:
Settings > your AirPods > Connect to This iPhone
> When Last Connected to This iPhone
On some versions you first have to open Audio & Routing. With this choice the AirPods only reconnect by themselves if this device was the last one they used. Otherwise you pick them yourself, from Control Center or the Bluetooth list.
The setting is stored per device, so repeat it on an iPad or a Mac that likes to grab them. On a Mac it sits under System Settings, Bluetooth, then the info button next to the AirPods, where you choose Connect to This Mac.
My advice is to change it only on the devices that steal audio. A phone is usually where I want automatic connection to stay, while a Mac in the next room can wait until asked.
The catch: you lose the nice part too. Picking up a call on another device no longer moves the sound over for you, and you have to switch by hand. If the option doesn’t appear at all, check that the AirPods are connected right now.
Further reading: Switch your AirPods to another device