

You can only turn it off when the phone is rooted - there is a Magisk module for that: https://github.com/Magisk-Modules-Alt-Repo/Disable_high_volume_warning
Or if your phone supports LineageOS, install that. It only shows the warning once and remembers your choice. At least for a looong time.
Only with Magisk: https://github.com/Magisk-Modules-Alt-Repo/Disable_high_volume_warning