Hello,
Do you have either AirPods Pro (both generations) or AirPods (3rd Generation)? Only those models are sweat and water resistant.
If they were exposed to an excessive amount of sweat or water it's important to let them dry before placing them back in their charging case. Charging while wet could easily cause issues.
About the sweat and water resistance of AirPods Pro and AirPods (3rd generation) - Apple Support
"After workouts, heavy sweating, or water splashes and before putting AirPods Pro or AirPods (3rd generation) into the charging case, wipe down your AirPods Pro or AirPods (3rd generation) with a soft, dry, lint-free cloth."
If you have one of the models that is water and sweat resistant you may be able to have the right AirPod repaired replaced under the Legal - Accessory Warranty English - Apple, if this issue is related to a manufacturing defect.
If your model is not one of the water and sweat resistant models but you do have an AppleCare+ plan you can likely seek repair or replacement subject to an accidental damage service fee.
AppleCare Products - Headphones - Apple
Either way, starting the repair process so you can figure out your options would be the best next step.
AirPods Repair & Service - Apple Support
I hope this helps.