Any way to change sound output device via Applescript or shell?
There's switchaudio-osx, command which needs to be compiled from sources or can be installed via homebrew (Xcode installation required):

brew install switchaudio-osx


Usage:

SwitchAudioSource [-a] [-c] [-t type] [-n] -s device_name



-a : shows all devices
-c : shows current device
-t type : device type (input/output/system). Defaults to output.
-n : cycles the audio device to the next one
-s device_name : sets the audio device to the given device by name