Try to record a voice memo and play it back over the earpiece speaker as opposed to the speakerphone speaker.
If you can hear the voice memo over the earpiece speaker, that means it's probably software related in which case a restore in iTunes might fix it.
If you still cannot hear the voice memo over the earpiece speaker, the speaker may be broken/defective in which case you are probably better off taking it back to Apple if it is under warranty. You can also try to [guide|4333|replace it yourself] if Apple will not.
I would try a restore in either case regardless just in case it would save me a trip to the Apple store.