set your yahoo options with your speaker. as you open your yahoo messenger, at the privacy policy you can find the option through which you can set the speaker or mic with the yahoo messenger.
Your speaker's already set by the system, not by yahoo messenger. If you want to change this go to Apple (top left menu) --> System Preferences --> Sound --> Output Tab