It's a known bug. I don't want to take the effort of digging it up, but there was a reddit thread about a month ago about this and someone linked to the steam forum post with tons of people having this issue and valve stating that they're working on a software fix.
Mine also does this. It's very annoying and sometimes I just plug in headphones while docked because of it. Other times I come out of sleep (specifically in persona 5) and the audio is weird and choppy, but I don't know if that's related.
I've noticed that my audio only cuts out and sounds crackly with some TVs. For some reason, changing the resolution seems to fix the issue (at least for as long as I have my Steam Deck plugged in). This is with both the official dock and a cheap Anker dock.
Yup! It seems that switching the resolution is the key. For me, at least, the sound works fine on every other resolution switch. I usually switch it to something lower, then something else, then back to the resolution I want. It's pretty annoying, but it doesn't take too long and is way less annoying than crackling audio.
IIRC it's a bug not specific to the Steam Deck, but something to do with the way Linux is handling audio. So the fix then is harder to get implemented since it isn't confined to code that Valve controls. Valve has to wait for the problem to be fixed in the greater Linuxosphere first, but I'm sure they're assisting with it.