Dear User,
Nitrogen has higher ionisation potential due to its half filled stable electronic configuration. The valence shell electronic configuration of N is 2s2 2p3, here p orbital is half filled which is a stable electronic configuration, Therefore high energy is needed to remove an electron from N.
On the other hand, O has electronic configuration 2s2 2p4, here by removing 1 electron, O attains half filled stable configuration, therefore low energy is needed and so it has low ionisation potential than N.