I was tired of having to manually connect the earphones every night to my computer and disconnect the speakers. So I decided to put a solution: construct a small "switch". All you need are some cheap pieces and some hours to work on it (how many depends on your experience).

What I've done is the following: put a switch which alternates between two female jacks (one to connect the speakers and one to connect the headphones). Both circuits are connected to the computer output through the switch. A very, very simple circuit. Everything is inside a small metal box, which I've attached in the bottom surface of the table. (You can also assemble everything inside your computer, if you want to avoid the extra box.)

That's all! Now switching to the headphones is a matter of pressing a button ;-)