This is a pattern of behaviour so you must find a way to break the pattern. Reducing amount masturbating will help if you cannot control your desires. Generally, masturbation is a normal part of sexual experience but like anything in excess, this will do more harm than good if out of control. Start off by looking at porn as usual, but dont masturbate. If you lose control, turn off computer. Take small steps to be free of a habit. Ask yourself how you would like to be treated as a person and do the same to others.
Make sure you find time to develop close relationships with someone you like and the urges you have for excess porn will diminish over time.