Your habit may have been precipitated by the events around a pregnancy, but it is not likely to be due to any medication.
However, medication can address such obsessive compulsive behavior. Eight years is a long time to put up with it. Please see your doctor or a psychiatrist for treatment.
Would you like to video or text chat with me?