It's just a myth. There are several factors that can make acne worse, but masturbation is not one of them. Acne is caused by overproduction of the skin oil known as sebum. Sebum can build up in a pore and become a hardened plug, creating a white head or a blackhead; the black coloring occurs when the top of the sebum plug is exposed to the air and undergoes oxidation. If bacteria infect the pore beneath the plug, the associated hair follicle may burst and create a pocket of inflammation, commonly called a pimple.
Sebum overproduction is common during puberty in response to changing hormone levels. Masturbation also generally begins during puberty, in response to the same hormones. The fact that the two occur during the same time frame probably led to the erroneous belief that one causes the other.
Masturbation is a natural, normal way for adolescents to explore their growing sexuality. It is physically harmless, but in some cultures and religions it is considered to be inappropriate behavior, and old wives tales that masturbation will cause acne, blindness, madness, or other maladies have been used for generations to discourage people from the act. However none of these stories has been found to have any basis in fact.
During the period of puberty, due to access of working of oil and sabecious glands, acne may occur, and it can may too occur due to different bacterias, such stapiloccoci (acne causing microbe).