All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Since the doctor recommended you to put that oil at night, then you should put it after the ‘Isha prayer and wash it before the Fajr prayer in order to avoid the problem of whether or not it is an obstacle that prevents the validity of ablution or Ghusl.
In case you must use that oil before the time of ‘Isha, and this oil is an obstacle that prevents water from reaching the hair, then when performing ablution, you may wipe over the hair that is not covered by it.
The Shaafi'i School of jurisprudence are of the view that it is sufficient to wipe over part of the head. It is confirmed that ‘Aa’ishah and Ibn ‘Umar did that, and it is not known that any Companion has ever objected to them [to their act].
You can also wipe over the Khimaar (head covering) and what appears from the hair, because wiping over the head covering is permissible according to the Hanbali School of jurisprudence.
However, it is a condition that the Khimaar be one that is difficult to remove in a way that it is attached around the throat but not when it is easy to remove it and wipe out directly over the head.
The scholars of Fiqh from the Maaliki School hold the view that it is sufficient to wipe over the henna in ablution if it is necessary for treatment, and it is not obligatory to remove it.
Mawaahib al-Jaleel authored by al-Hattaab, from the Maaliki School of jurisprudence, reads:
“He (i.e. Imam Maalik) said in al-Mudawwanah: ‘If there is henna on the head, then she does not wipe over it until she removes it and wipes over the hair. The author of at-Tiraaz said: “Putting henna for necessity and medication, such as due to fever and the like, then it is permissible (to wipe over it) and it is not obligatory to remove it, like the Qirtas (a covering) over the cheek; but if it is not for a dire necessity, like the issue in question, then it is not permissible for him to wipe over it because it prevents reaching the head by wiping it, like the garment. Ibn Farhoon said: ‘Al-Lakhmi said: ‘if there is henna on his head and it was for a necessity, then it is like the oil (cream), it is wiped over, like an obstacle, but if it is not for a necessity, then no….” [End of quote]
In regard to the obligatory Ghusl, it is necessary to remove that oil that that is used without necessity and which prevents the water from reaching the skin, and it is not sufficient to wash part of the head only.
The Fiqh Encyclopedia reads: “The scholars of Fiqh agreed that it is obligatory to pour water over the hair of the head, both on its top and (until) its roots, for the male and female, whether the hair is straight or otherwise.” [End of quote]
As regards when there is a necessity, one should wipe over it in the same manner that he wipes over the splint (plaster), as already mentioned in the statement of Ibn Farhoon: “If he has henna on his head and it was for a necessity, then it is like an ointment (cream); it is wiped over, just as an obstacle………” [End of quote]
Moreover, the Fiqh Encyclopedia reads:
“The scholars of Fiqh agreed on the permissibility of wiping over plasters (splints), when there is an excuse, instead of washing, or original wiping over in ablution, or Ghusl, or Tayammum.”
Allah knows best.