Note that in this case, there is just one audio card (card 0), with multiple output devices, one of which is the HDMI output.
PulseAudio/Pipewire
If you use PulseAudio or Pipewire, they should automatically remember the chosen output device for each audio-producing application if you choose it once, and for programs that have not produced audio before, they will use whichever output is marked the "fallback" with pavucontrol or similar PulseAudio configuration tool.
If you need to do this on the command line, first make sure the correct card profile is used. Use pactl list cards to find the card names and the available profiles for each:
pactl set-card-profile <card name> <profile name>
For HD Audio integrated in an Intel chipset, it would probably be something like:
pactl set-card-profile alsa_card.pci-0000_00_1f.3 output:hdmi-stereo+input:analog-stereo
Then run pactl list sinks and find the sink name and port names for your audio card. In the output, it will look like this:
Sink #<sink number> State: SUSPENDED Name: <here's the sink name you're looking for> [...some stuff indented at this level...] Properties: [...a lot of stuff indented at this level...] Ports: <here are the port names> Active Port: <something> Formats: [...]
Since you apparently have the HD Audio integrated into Intel chipset, the sink name is most likely alsa_output.pci-0000_00_1f.3.hdmi-stereo. Then find the names of the ports available for that sink in the Ports: section for that sink. It might be something like hdmi-output-0.
Once you know the names, you can use them in a commands like this:
pactl set-sink-port <sink name or number> <port name>
i.e. probably something like this:
pactl set-sink-port alsa_output.pci-0000_00_1f.3.hdmi-stereo hdmi-output-0
For PulseAudio, you could make it a system-wide default by adding the set-sink-port command to /etc/pulse/default.pa:
set-card-profile alsa_card.pci-0000_00_1f.3 output:hdmi-stereo+input:analog-stereo set-sink-port alsa_output.pci-0000_00_1f.3.hdmi-stereo hdmi-output-0
But note that any remembered per-user and per-application settings will normally override the system-wide PulseAudio defaults anyway.
Plain ALSA
If you use just plain ALSA, then you could place something like this in your ~/.asoundrc:
defaults.pcm.!card 0 defaults.ctl.!card 0 defaults.pcm.!device 3 defaults.ctl.!device 3