The issue persists even in the latest version of the Ubuntu flavored OS for the Pi, 22.04.

It reduces cable clutter and also the need for additional external speakers.

First up, you better peek if HDMI audio is working alright, by selecting it manually.

Raspberry Pi 3 with HDMI cable and a speaker

For that, you should probably find the unit name first.

Identify the HDMI Audio unit

The commandpactlcan control a running PulseAudio sound server.

A source is the input unit, and a sink is the output unit.

3.5mm default audio for Ubuntu Desktop on Raspberry Pi

List all the available audio output devices on the Raspberry Pi:

Note down the gear withHDMIin the name.

Configure to Make HDMI the Default Audio gear

Search forStartupApplications Preferencesand open it.

ClickAdd Startup Programand fill in these details:

ClickAdd.

Manual selection of HDMI audio for Ubuntu on Raspberry Pi

Get list of audio output devices using pactl on Ubuntu

Add a startup command to set HDMI audio as default on Raspberry Pi

Startup Applications window for Ubuntu Desktop on Raspberry Pi