i have this problem too, your computer (motherbaord if self built) probably came with a software to change the sound output when you unplugged a sound jack (you should see it in the notification tray in windows) and mine automatically asks me what i plugged in when i plug it in, this enabled me to use headphones on the mic jack, or like 4 headphones at once haha.
back to the point, im guessing your using a recent version of ubuntu so click the small speaker in the top right of your screen, then from the menu that appears click sound settings...
Under the output tab (should be already selected) you will see on the left the option of play sound through?
try clicking all the devices and options in that box with music playing
if it helps then you are welcome, its not always as complicated as windows, ubuntu is in some cases easier than we are used to:)