Pimples can occur anywhere on the surface of the skin when ever pores become clogged up by dead skin and other debris. However, I think it is more likely that what you are dealing with here is something called folliculitis. Folliculitis is a condition in which infection from bacteria occurs at the base of the hair shafts, leading to redness and swelling around individual hair shafts. This can be usually easily cleared up with good hygiene, such as washing the affected areas with an antibacterial soap and applying an antibacterial ointment.
Another possibility would be seborrheic dermatitis, which is an inflammatory condition of the skin that causes scaly, itching plaques. Sometimes these plaques may be mistaken for pimples and, furthermore, they may become secondarily infected, leading to pimple-like formations.
I would suggest that you go see your primary care doctor
. They will be able to take a look at your scalp and will be able to tell you which of these conditions you might have. If you do have seborrheic dermatitis, then there are several anti fungal and anti inflammatory lotions and creams that can be very effective at clearing up the areas of inflammation.
Good luck sorting this out!