Sound output doesn't change automatically after connecting to Bluetooth headset

I had the same problem on Ubuntu 18.04, and I solved it by just copying the file default.pa from /etc/pulse/ into /home/username/.config/pulse/ and it's working.

And now everytime you connect or disconnect the sound output will be changed automatically.

cp /etc/pulse/default.pa /home/username/.config/pulse/

Look for pulse audio volume control in Ubuntu software center. One of them (unfortunately has the same "plated" button icon) has a way to choose how the audio will be consumed and even allow to be send to multiple outputs at the same time. Once installed, open it and if the audio is streamed out through your speakers, you can choose your bluetooth output (once the bluetooth output is conected and paired of course). I know is not the best way, but at least you don't need to do all the dance you have to do to make it work.