I have a pair of headphones from Pioneer and every time I plug them in, for awile the sound will be through headphone, than they kinda disconnect and the sound will go through speaker.
Is happening only with this devices and only with this pair of headphones, and it doesn't matter the app.
But I found that if I keep the headphones connected and I restart the device, after that the headphones will not disconnect until I do. After I connect back the headphones the problem appears again.
I'm on Android 8.1 and I remember that I didn't had this problem on Android 8.