Praise be to Allah.
Lanolin is a fatty yellow substance that is extracted from sheep’s wool; it is also known as wool wax or wool grease. See: https://en.wikipedia.org/wiki/Lanolin
There is nothing wrong with consuming food that contains lanolin, if it is extracted from sheep’s wool.
If the sheep was slaughtered in the prescribed manner, then the matter is clear, because it is an animal that is regarded as pure and its flesh may be eaten, and it has been slaughtered in the prescribed manner. So there is no doubt that its hair (wool) and other parts are pure.
But if the wool was taken from it when it was alive, or it was not slaughtered in the correct, prescribed manner, then the more correct scholarly view is that the hair of all animals is regarded as pure, even if the animal was not slaughtered in the prescribed manner.
Shaykh al-Islam Ibn Taymiyyah (may Allah have mercy on him) said:
All hair, feathers and wool are pure, whether they are from an animal that may be eaten or the skin of an animal that may not be eaten, and whether they were taken from an animal that was alive or dead. This is the most likely to be correct of the scholarly opinions. End quote from Majmoo‘ al-Fataawa (21/38)
See also the answer to question no. 176304
Even though there is a view that wool and hair are impure in general terms, if they are not taken from an animal that was slaughtered in the prescribed manner, this (lanolin) is a substance that is extracted from the wool, so it is no longer of the same nature as the impure hair from which it was taken; rather it has turned into a different substance, and has become – through this process of istihaalah (transformation) – pure and halaal.
See the answers to questions no. 248124 .
For more information, please see the answer to question no. 102749
And Allah knows best.