Source: Anonymous comment to blog post Switching default PulseAudio device when USB microphone is plugged in
PulseAudio has built-in support for defaulting. Just add
# automatically switch to newly-connected devices
load-module module-switch-on-connect
to /etc/pulse/default.pa
right after these lines
### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available
Then restart server pulseaudio -k