Does masturbation causes knee pain if not what is its side effects and how can it is controlled what food you doctors suggest?

No. I will assume that this is a serious question. Knee pain would be unrelated. Diet probably has not effect. Have a doctor evaluate the knee pain to dtermine its cause.
Masturbation. Maybe it depends on what position you're using to masturbate. For example being on your knees on a hard floor could result in knee pain. Otherwise there would be no relation. "side effects" would be release of pent-up sexual tension, rather than anything harmful. Unless you're doing it compulsively many times a day or in public places, it is a safe activity that can be enjoyed ad lib.
You sound confused. Knee pain is not related to masturbation. If you find your habits disturbing to you i would suggest a 12 step program plus talking to a sex therapist with experience with this problem.