Welcome to e health forum.
Varicocele is a condition, occurring due to damaged valves inside the veins along the spermatic cord, which prevent blood from flowing properly. This causes the blood to back up, leading to swelling and widening of the veins. A varicocele is usually harmless and often does not need to be treated especially when it is asymptomatic. Treatment is necessary only when it causes pain, shrinkage of a testicle, or when it is associated with male infertility.
The condition is not associated with masturbation or due to sex related activities.
Wearing a jock strap (scrotal support) or snug underwear may help relieve the pain or discomfort.
In case the condition is severe, you can consult a urologist, who can treat the condition with a procedure called Varicocelectomy or a varicocele embolization.
I hope this helps.