Is it possible to switch between headphones and speakers by software control? I'm disabled, and plugging and unplugging my headphones is rather difficult for me. I'd rather just press a button and find sound output switched to another output device, is this possible?
If they are on two different interfaces, this should work. Then you can go into the sound settings and select your output hardware.
In case they are the same interface, like plugging in the headphones disables the speakers, this will probably not work. You could buy something like this cinch switch then, though. Or you buy a little USB sound card in order to have two interfaces to use solution 1.
Yes it is possible to do that only if you have 2 sound cards, then you can configure your software output to do that. You can find USB based external sound card that supports ubuntu.
However since you mentioned you were disabled and finding it difficult to move around each time, i would advice you to consider to use a 'Y audio splitter' aka 'headphone audio splitter', they can be found for very low cost (compared to an external sound card).
I am presuming that your speakers and headphones have on/off controls and you can access those buttons easily. This is how the splitter looks, some brands have individual volume control as well.
If you dont have access to ON/OFF & volume controls on your speaker & headphones, You can use both of them in combination to suit your needs. You could also use this in combination to a cinch switch as well.
I know that this is not the exact answer to your question, but i hope it solves your problem.