If the chastity device gets in the way of your health, your health should always come first. A reasonable path is to talk to your keyholder if you have one, so you both can look at your situation and see what needs to be done to take care of your health, and, if necessary, by what alternative means your chastity can be protected. Without a key holder, you will need to make that decision yourself.
For a girl who mainly wears the belt to abstain from sex with a partner for example, a reasonable concession would be no going out or receiving visitors while the belt is off - a good idea to stay alone in bet while sick anyway and nobody can take her virginity like that. If masturbation is a concern, open door and random checkups.