You can disable that if you root your phone or install a custom ROM. Just saying.
Although Google is getting on my nerves lately so I've been thinking of switching anyway.
This should be a disclaimer when buying the phone then.
The user can choose to override the limit so that the sound level can be increased up to maximum 100dB. If the user overrides the limit, warnings about the risks must be repeated every 20 hours of listening time. "
via http://www.bbc.com/news/health-21294537
The "repeated every 20 hours" would explain why OP was seeing the warning seemingly randomly.