Regarding washing on Yom Kippur, the Tur (OH 613) writes:
ביה"כ...ואם היו ידיו מלוכלכות בטיט וצואה מותר לרוחצן שלא אסרו אלא רחיצה של תענוג ...וכן בכל היום אחר שעשה צרכיו וקנח או הטיל מים ושפשף בידיו וכתב גאון מי שהוא איסטניס וצריך לקנח פניו במים ואין דעתו מיושבת עליו כל היום עד שיקנח יכול לקנח בי"ה וכ"כ רי"ץ גיאת אם יש ליכלוך על פניו או על גבי עיניו יכול להעבירו במים
That is, if one's hands are dirty it is permissible to wash them, since they only forbade washing for enjoyment. A Gaon wrote, that someone who is extremely particular and feels the need to wash his face with water, and remains unsettled until he does so, may wash himself.
The Tur (OH 554) applies this to Tisha B'av as well:
ומיהו צריך ליזהר שלא ליטול כל ידיו אלא לפי הצורך להעביר הלכלוך ואפי' שלא לצורך ברכה ותפלה אם היו ידיו מלוכלכות בטיט וצואה ורוחץ אותם להעביר הטיט והצואה ואינו מכוין לתענוג מותר שלא אסרו אלא רחיצה וסיכה של תענוג כדאיתא בגמרא
And is in turn cited by the Shulhan Arukh (OH 554:11), and many others agree. (a)
Thus, On Tish'a B'av it would be permissible for a person to wash his hands (or other parts of his body) based on the perception of dirtiness, real or not.
It is noteworthy that most people with OCD are aware that their compulsions are based on irrational obsessions, and this causes them pain; the very opposite of pleasure.
(a) Shibbolei HaLeket ch. 29, Meiri (Ta'anit 30a), Nishmat Adam ch. 145, and Yalkut Yosef Dinnim L'isha u'l'bat notes to ch. 47 who all agree that washing that is not for pleasure is permitted on the ninth of Av, just like on Yom Kippur.