To my Rasbian setup I have a set of speakers connected via the headphone jack and it works just fine when I start the RasPi (3b+) with a connected HDMI screen, also when accessing it via a web portal (Phoniebox). When I disconnect the screen with the RasPi running, still everything works. However, when I restart the RasPi in headless mode the HDMI screen disconnected it goes silent. I can see from the phoniebox web application that songs are not played when I hit play.
I assume that the audio ouput is switched to HDMI as soon as I disconnect the screen? Is there a way the check this assumption?