Ruling on a man offering condolences to a woman
Question

Is it permissible for a man to offer condolences to a woman, or for a woman to offer condolences to a man?
Praise be to Allah.It is Sunnah for a Muslim to offer condolences to his brother; this includes both men and women.
But Islam bars the way to fitnah (temptation) and seeks to ward off negative consequences and evils as much as possible. For a man to offer condolences to a woman, or vice versa, may allow the Shaytaan to make inroads. Hence the scholars have stated that a man should not offer condolences to a young woman unless she is one of his mahrams.
In the case of an old woman, some of the scholars granted a concession allowing offering condolences to her, because she is not like a young woman in terms of there being any fear of her being a cause of fitnah. Nevertheless, it is better to refrain from offering condolences to her too.
It says in al-Ghurar al-Bahiyyah (2/124): No men should offer condolences to a young woman except her mahrams and her husband. End quote.
In Hashiyat Ibn ‘Abidin it says: It says in Sharh al-Munyah: Offering condolences is recommended (mustahabb) for men and women who are not a cause of fitnah…"(Radd al-Muhtar  2/240).
Sahnun said: Condolences should not be offered to a young woman and may be offered to an old woman, but not doing so is preferable."(Mawahib al-Jalil (2/230). See also: adh-Dhakhirah  2/481).
Ibn Qudamah (may Allah have mercy on him) said: A non-mahram man should not offer condolences to young women, for fear of fitnah."(Al-Mughni  2/212).
And Allah knows best.