Change Sound Output Script?

Audio Switch for Alfred:

See also

which has detail on some underlying scripts that should be applicable if you’re not using Alfred.