All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
First of all, we advise you to consult a doctor about your condition as it might be a physical or psychological problem.
If you act in the way you described in the question while being unconscious, then you are considered as sleeping and the Prophet said: "The pen is lifted (stopped from writing the deeds) from three kinds of people: the sleeping person until he wakes up, the mentally-handicapped or insane person till he becomes able to reason, and the child till he grows up (reaches the age of puberty)." [At-Tirmithi] But if you act in such a way out of anger while being conscious about it, then you will be accountable for your behaviour and whatever evil you may cause.
As regards a religious treatment for this, then we advise you to recite the legislated mention of Allaah when going to sleep, like reading verses: 255, 285 and 286 from chapter: 2, and chapters: 112, 113 and 114, and sleep while in a state of ablution. You should also recite the legislated mention of Allaah in the morning and in the evening. [We hope that if you do so, you will be cured as the Quran is a mercy and a cure to the believers].
Allaah Knows best.