Will apple give me a replacement iphone?

So my iphone's earpiece is almost muted and i can't hear a thing when someone calls me so i always have to put it on speaker for it to work.

Take it to the store and see. If it's within their warranty period and not water damaged, they should either fix or replace it.

They will have you do some stuff like reset the iphone, reset the settings and back it up and restore it as new but if it persists after all of that if you're still within warranty they will. If you're out of warranty they will still do it but there's going to be a fee.