Welcome to Android Central! Do you mean a Galaxy S8 or Note8? When you say "earpiece," do you mean a Bluetooth headset, or are you talking about the phone's earpiece speaker?
If you mean that the phone's earpiece speaker doesn't work, then make sure the opening isn't clogged with debris. If it's clear, then the speaker probably failed -- you'd have to bring it to a repair shop.