Here's why:
* Electronegativity is the measure of an atom's ability to attract electrons towards itself in a chemical bond.
* Oxygen has a higher electronegativity than nitrogen because it has a smaller atomic radius and a higher nuclear charge (more protons in its nucleus). This means that oxygen's nucleus attracts electrons more strongly than nitrogen's nucleus.
You can see this trend in the periodic table: electronegativity generally increases as you move across a period (from left to right) and decreases as you move down a group.