In Islam there are exceptions allowed for people in times of necessity. If your medical condition requires that you should take off your hijab, you may do so until such time that your condition improves, without incurring sin. However, it is best advised to try other alternatives such as taking a vacation in order to avoid displaying your hair in front of non-mahrams. You can also cover your hair only in the presence of male non-mahrams. If this is not possible, then you may uncover your hair until your condition improves.
Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: If your condition is unbearable for you and the dermatologist has advised you that you can only get relief by temporarily taking off your hijab, then I think you fall in the category of those who are excused. In Islam there are exceptions allowed for people in similar cases. This can be proven by pointing to the concession the Prophet (peace and blessings be upon him) allowed to some of his Companions to wear silk because of their medical condition, even though wearing silk in general is haram (unlawful) and therefore considered as sinful for men in ordinary circumstances. Likewise, if your medical condition requires that you should take off your hijab, you may do so until such time that your condition improves, without incurring sin.
But I must caution you against resorting to this action purely on your own personal likes or dislikes; it can only be done if there is a genuine medical reason. For exceptions in Shari`ah are simply exceptions and not general rules. They are bound by specific conditions and circumstances in such a way that the allowance is lifted as soon as the condition or circumstance changes.
Sheikh `Abdul-Majeed Subh, a prominent Azhar scholar, adds: First of all, try to take a vacation at this period and to stay home in order to avoid displaying your hair in front of non-mahrams. If this is not possible and you are in need to work, then you can try to cover your hair only while working and when you come back home, uncover your hair. Also, if, depending on your work, there are times at work when male non-mahrams are not present, you can uncover your hair.
But if we suppose that this is not enough, then this is an excuse for you to uncover your hair until your condition improves if you are in need to work.