clearly this did not happen on the first day you started using the device, so its either a bug or an app that is automatically turning on the speaker.
do you have any recording apps that record conversations? 'call recorder' type apps? if so, there may be a setting that turns this function on.
or if you don't,
what did you do to the phone prior to nociting this? did you delete or install an app? did you mess around with any 'accessibility' type settings on the phone?
how long have you had the phone? are you new to android? what is your carrier?
are you rooted?