Apple has announced a service program for owners of the iPhone 12 and iPhone 12 Pro. Apple's concluded that a "small percentage" of 6.1-inch iPhone 12 devices have an issue where no sound comes from the earpiece during a phone call. Apple will replace the faulty module free of charge. This is not applicable to the iPhone 12 mini or the iPhone 12 Pro Max.
Apple has determined that a very small percentage of iPhone 12 and iPhone 12 Pro devices may experience sound issues due to a component that might fail on the receiver module. Affected devices were manufactured between October 2020 and April 2021.
If your iPhone 12 or iPhone 12 Pro does not emit sound from the receiver when you make or receive calls, it may be eligible for service.
Apple and Apple Authorized Service Providers will provide the service free of charge. Users with speaker issues need to make an appointment with an Apple Retail Store, Authorized Service Provider, or contact Apple Support for mail-in service.Apple iPhone 12 Pro
Apple advises users to back up their data either to iCloud or to a computer before their appointment. In addition, Apple won't service earpieces on iPhones that have damaged displays and will require that it's fixed before it will fix the earpiece issue.
Check the source link to see the full repair service announcement.