Changing Sound Outputs w/Applescript (I seem to have misplaced my tab group)
While the other answer does in fact work for me on my system running macOS High Sierra nonetheless, I have to post a KISS principle answer.

Simply add the following code to your existing code:

repeat until exists tab group 1 of window "Sound"
    delay 0.1
end repeat


So your code will now look like:

tell application "System Preferences"
    reveal anchor "output" of pane id "com.apple.preference.sound"
end tell

tell application "System Events" to tell process "System Preferences"
    repeat until exists tab group 1 of window "Sound"
        delay 0.1
    end repeat
    tell table 1 of scroll area 1 of tab group 1 of window 1
        select (row 1 where value of text field 1 is "Andrea Comm USB-SA Headset")
    end tell
end tell

quit application "System Preferences"


There most definitely is a level of sophistication to the other answer; however, I'd imagine it may be a bit difficult to understand for those who are new to AppleScript and why a KISS principle answer is being provided.