`SwitchAudioSource -a` only reports the Airpods after they've been connected at least once since your Mac has been awake (or maybe there is a timeout, I haven't thoroughly tested).
As a result, this workflow only works after having already connected the Airpods once. Is that the intended behaviour, or has this changed in 10.13?