The Hindu treatise on sex Kama Sutra (4th to 6th centuries AD) does
not condemn masturbation at all and moreover explains in detail the
best procedure to masturbate; "Churn your instrument with a lion's
pounce: sit with legs stretched out at right angles to one another,
propping yourself up with two hands planted on the ground between in
them, and it between your arms".
According to Hinduism, life begins at the Brahmacharya or "student"
stage, in which they are directed to chastely advance themselves
educationally and spiritually to prepare themselves for a life of
furthering their dharma (societal, occupational, parental, etc.
duties) and karma (right earthly actions); only once they reach the
Grihastya or "householder" stage can they seek kama (physical
pleasure) and artha (worldly achievement, material prosperity) through
their vocations. Sexual pleasure is part of kama, one of the four
goals of life. Source:(1,2).
So Mastrubation is not a sin in Hinduism but its only allowed in "Grihastya Jeevan".