In a covalent bond, two atoms share one or more electron pairs. If the electrons are shared equally between the atoms, the bond is nonpolar. If the electrons are shared unequally, the bond is polar.
In the case of O2, the two oxygen atoms share two electron pairs equally. This means that the electronegativity of each atom is the same, and the electrons are pulled evenly towards each nucleus. As a result, the bond is nonpolar.