It depends upon the brand, if it is Apple or Beats, not other brands.
Here's the warranty information for USA accessories. If you are not in the USA then go to the second link and work you way down.
Apple One (1) Year Limited Warranty – Accessory - For Apple and Beats Branded Products Only.
https://www.apple.com/legal/warranty/ - select item then country then language