Anas, may Allah be pleased with him, narrates:

A man came to the Prophet and asked him:

“O Allah's Messenger, peace and blessings upon him, my eye aches; I apply eyeliner although I am fasting (Does it invalidate my fast?)”

Allah's Messenger (PBUH) replied: “No (it does not invalidate)” (Tirmidhi, Sawm: 30)

From the hadith (saying of the Prophet), the following rules are understood:

1- Applying eyeliner on the eye does not invalidate the fast.

2- The medicine put on a wound on the head or the stomach does not invalidate the fast as long as it does not penetrate into the body.