The expression "get yourself off" is a popular slang for masturbating. "To get off" is an idiom or popular saying used to express finding something extremely gratifying or enjoyable.
Intercourse is meant to be gratifying and enjoyable, so the idiom "get off" came to mean having an orgasm. "Getting yourself off" happens when someone pleasures themselves.
I don't know when this particular slang term started but it is now well ingrained in the English language.
Slangs usually start in a sub-culture that is out of the mainstream.
This set of people use informal words or phrases to describe things in ways that is often not recognized by outsiders, and if you go to a different sub-culture the same slang word might mean a totally different thing.
Depending on how much interaction and influence this sub-culture has with the mainstream, the slang words might reach to the forefront of society and become a word used by everybody.
For example, a few years ago the slang word "trill" (meaning cool, flashy, stylish) came to prominence because a lot of different rappers began using the term in their music.
Even though the slang "trill" had long been a part of the local talk in different Southern states of America it only became absorbed into wider American culture years later when people with influence (the performers) made everyone else aware of it. Soon, young people from all walks of life (not just from the South) added the word "trill" to their vocabulary and a popular slang was born.