I have Harmon Kardon speakers and after 20 minutes of troubleshooting, resolved 3 issues which now have my speakers working: 1) volume button on front of speakers had been turned down, plugged my speakers into an iphone to prove they worked and discovered the issue... 2) "Headphones" wouldn't show up as an option in system preferences menu when speaker jack was plugged into headphone output on mac. Tried several things to make this work, turns out, I have a touchy connection at the plug that goes into the mac. With the system preferences Sound menu open, I got the menu entry to change from "Internal Speakers" to "Headphones" just by wiggling the plug on the back of the imac. Fortunately I could position it such that "Headphones" would always stay on and selected. 3) I have Apple TV which I have used to play tunes off the imac with the "Home Sharing" feature. Even though Home Sharing shows as off in the Itunes menu, I found a menu selection at the top of Itunes that has two entries, one says "Computer" and one says "Apple TV" and you guessed it, "Apple TV" was still selected even though I believed Home sharing was off. I selected "Computer" and voila, speakers work great.
Not sure this solves your problem, but wanted to post this in case others have issues.