I'm not sure if this post is too old to respond to but I do the same thing. It first occured two years ago and caused issues in my marraige. I was seeing a phyciatrist because I am bipolar and thought it was somehow related. He's never seen a case like that before, but thought it was stressed induced and that masterbation may have provided some relief. He recommended that I excercise regularly to relieve some of that tension. I went back to exercising again and it seemed to help.
I also did some online research and it is a sleep disorder. People who sleep masterbate can seem wide awake as in my case where my eyes are fully open and I would act sneaky about it. For a while my husband wouldn't believe that I didn't know I was masterbating. It was a very scary time for both me and my husband.
Hopefully exercise may help, or also seeing a phyciatrist. Perhaps there are psychological reasons- stress, need to vent, or need of comfort.