1. They are having an election for school president.

2. They are having an election for the school president.

3. They are having an election for a school president.

(Which one is grammatical and commonly used?)

They are all grammatical. I'd say that 1 is most common.