pacmd "failed to set sink port" when trying to change which output on my sound card to use

Solution 1:

From output of your list-sinks we can see that by default your headphone sink has index 1, your speakers sink has index 2 (HDMI is 0). Provided you have a default setup for PulseAudio you should be able to switch between these two sinks by issuing:

pacmd set-default-sink 1 # for headphones
pacmd set-default-sink 2 # for speakers

See also this answer for changing sink output while an active stream is playing and how to disable stream device restore.

Solution 2:

Surrounding the port name by quotes("...") worked for me. So try

pacmd set-sink-port 2 "analog-output;output-headphones-1"