To clarify, a triple bond between carbon and oxygen is more stable than a triple bond between carbon and nitrogen because oxygen is more electronegative. Is my understanding correct?

Yes, your understanding is correct. A triple bond consists of three pairs of electrons being shared between two atoms. The more electronegative an atom is, the more strongly it attracts electrons toward itself. In the case of a carbon-oxygen triple bond and a carbon-nitrogen triple bond, oxygen is more electronegative than nitrogen.

As a general rule, the more electronegative atom in a bond will have a greater pull on the shared electrons, which creates a polarization of charge. In the case of a triple bond, the electron density is concentrated between the carbon and oxygen or carbon and nitrogen atoms.

Oxygen's higher electronegativity means it has a stronger ability to withdraw electron density from the carbon atom, which results in a greater degree of polarization and stability for the carbon-oxygen triple bond compared to the carbon-nitrogen triple bond.

To determine the relative electronegativities of different elements, you can refer to the periodic table. Electronegativity values often follow a trend: electronegativity generally increases as you move from left to right across a period and decreases as you move down a group.