Masturbation does not impact hair transplant surgery. It would not impact the transplanted hairs nor the neighboring hairs.
Masturbation has zero affect on your hair in any way, shape or form. Hair loss is most commonly caused by DHT and treatments such as Finasteride, Minoxidil and PRP will help to slow the loss of hair.