Can you have pimple in your mouth and what cause it.

Not a pimple, but... "pimples" do not occur inside the mouth. If it is near a tooth, it's probably an infection, also known as a fistula, trying to break through to the surface to relieve the pressure. If it is on the inside of your cheeks or lips, it may be a blocked salivary duct, known as a mucocele. See a dentist to determine what it is and what treatment is necessary.
Several causes. By definition a pimple is an infectied hair follicle which do not exist in the mouth. This could be an obstructed salivary duct, an infection of the skin or related to a dental problem. It needs to be evaluated by a physician.
Infection. "pimples" in the mouth are usually an abcess (infection) of either the gum itself or the nerve of a tooth whose root is in the spot the "pimple" occurs. You need to see a dentist to properly diagnose and treat this.