Reasons for the iPhone 7 Plus earpiece problem probably are below:
The first one may be that your iPhone 7 Plus went wrong on operation system or software glitches and so on. This is definitely the easiest one to fix. All you need to do is restarting your phone. That might work on some devices.
The second one may be the hardware problems. It could be a little complicated. You need to open up your iPhone 7 Plus and examine the earpiece flex cable. After opening up, check if there has any visible shifting or damages on the tape, the connector and the flex cable. The solution for this situation is to reseating or replacing them. Here is the guidance for you.
Remove the two bottom pentalope screws, and suction the glass up.
Unscrew the Phillips screws from the earpiece speaker & front-facing camera bracket.
Take off the earpiece speaker & front-facing camera bracket from the front panel.
Lift the front-facing camera in the front panel.
Holding the front-facing camera, take out the earpiece speaker from the front panel.