I figured out the solution while writing this question. But I’m posting it regardless, for the benefit of others.
I’m running Fedora 36 with KDE Plasma on Wayland. I went into the audio settings on KDE, which looks like this:
While trying to scroll down with a touchpad, my cursor was in the vicinity of the Profile setting for my Built-In Audio output (or maybe input?). Something got selected by mistake, and then the output device just disappeared from the settings. The device where the change was made is not visible on the screen above. And now my audio from built-in speakers doesn’t work. If I connect my bluetooth headset, that works fine. If I connect wired headphones, these don’t work as well.
I tried to understand how audio works on Linux, and without having too much experience with it, I’m utterly confused. Can anyone help me find the place where I can undo whatever got changed in the settings?