How to fix iPhone 3GS? Can't hear when on a call unless is on speaker?

When I'm on a call on my iPhone 3GS I can't hear anything, but as soon as i put it on speaker I can hear fine, Please help thanku

Either the volume is turned right down or the speaker is broken, when you put it onto speaker it swaps to the speaker at the bottom of the iphone as opposed to the one on the front used for calling.