I had someone a while back complain they were having a having a hard time hearing when on the phone. When I replaced the screen I missed a piece of the clear plastic protector on the front of the screen, once I removed it everything was okay.
Have you disassembled the phone and checked the connectors? Your connector for this is at the top of the phone. Make sure it is all assembled correctly. Make sure the metal prongs are connected under the bracket (not sure how to explain this. You have the metal bracket and then a black peice of ribbon cable sits on top of the microphone. On the earpiece there is 4 i believe metal prong things. They need to be sitting under the ribbon cable. The ribbon cables has spots on it that the microphone connects to. You may need to clean the connectors. Look at the ifixit guide to see how it all gets assembled correctly. Also make sure the connector is properly seated to the logic board.
I would also do a reset by holding the power and home button. While the phone is on, hold these two buttons until the Apple logo appears and then let go. See if this fixes it. If it doesn't continue on!
Have you tried switching to speaker and seeing if that works? You should also go to like Memos and make a new one and talk so it records you and see what happens. If it records you and you can hear everything fine, then its not the hardware. Do other sounds work?
You can also try going to settings and then clicking the reset all settings button and see if that helps.
Unless anyone else had any other ideas I would say you would have to do a factory reset if nothing else worked.
I think a reset or checking the assembly will fix this issue. If you do need to clean anything use 99% isopropyl alcohol. Let us know what hapoens!! Good luck!