masturbation done for the purpose of getting over lust for someone. The "it" in "rub it off" is the sexual attraction.
The term is similar to brush it off, but is explicitly sexual.
If a
hater talks shit to you, you can brush it off and get on with your life. If a bad bitch is stuck in your
head, you can't brush it off: You gotta rub it off.