Assuming it is the earbuds that are exhibiting an issue, it really kind of depends on the issue and what is not working about them. Could be wiring (which is usually the culprit most of the time). And alternatively the Jack where the earbuds go in (could be the next culprit), the earbuds (speaker portion) could be failing(not as likely), or the jack on the earbuds themselves (which is least likely).
Apples Troubleshooting guide:
If your headphones don't work with your iPhone, iPad, or iPod touch
Get help when you can’t hear sound from your headphones, your microphone doesn't work, or the buttons on your remote don't work.
Check for debris, damage, or loose connections
1.Check for debris in the headphone port on your iPhone, iPad or iPod touch.
2.Check your headphone cable, connector, remote, and earbuds for damage, like wear or breakage.
3.Look for debris on the meshes in each earbud. To remove debris, gently brush all openings with a small, soft-bristled brush that's clean and dry.
4.Firmly plug your headphones back in. If your iOS device has a case, remove the case to get a firm connection.
If your headphones still aren't working, follow the steps below for your issue.
If you can't hear any sound or if only one side of your headphones works
1.Adjust the volume with the volume buttons on your iOS device or use the Volume slider in Control Center.
2.To see if you need a replacement, try a second pair of headphones. If the second pair works, contact the manufacturer of the initial pair and ask if you need a replacement. If the second pair doesn't work, contact Apple Support.
If your device gets stuck in headphone mode
If your headphones are unplugged from your iOS device and you still see a Headphones volume indicator on the screen, get help.
If your microphone doesn't work
1.Make sure that your headphones have a built-in microphone.
2.Check your microphone for blockage, like debris, lint, or plastic packaging.
3.To see if you need a replacement, try a second pair of headphones. If the second pair works, contact the manufacturer of the initial pair and ask if you need a replacement. If the second pair doesn't work, contact Apple Support.
If the buttons on your Apple EarPods don't work
1.Check for debris in the gap between the top and bottom covers of your remote.
A remote on the cable of the Apple EarPods
2.Gently tap the remote to dislodge debris. If you still see debris, brush it away with a soft-bristled brush that's clean and dry.
If your remote still doesn't work, contact Apple Support.
If your headphones aren't detected
If you plug in your headphones, but sound plays from your device's speakers, try plugging in a different pair of headphones. If the same thing happens, get your device inspected at an Apple Retail Store or Apple Authorized Service Provider, or contact Apple Support.