I will try to make a picture of what I did. I bought a splitter like this one.
The sound quality of the desktop speaker is good when I plug the it alone. Then after plugging this device and connecting both the speaker and the headphone, the sound quality of the speaker would become like the sound quality of the headphone.
I bought this device so that I won't be plugging and unplugging the speaker and the headphone all the time.