Dipole moment can be defined as the product of magnitude of charge and the distance of separation between the charges. A dipole exists when two or more atoms with different electronegativities are bonded together to form a molecule. The resulting unequal sharing of electrons leads to a molecule with a net positive and a net negative end. Hence the molecule is said polar.
Bonds between carbon and oxygen (C=O) are more polar but carbon dioxide (CO2) does not exhibits a dipole moment because CO2 is a linear molecule and the charge is equally distributed amongst the entire molecule. When molecules have an even charge distribution then there is no dipole moment and the molecule is said to be non-polar. CO2 is a linear molecule, so the dipoles are symmetrical and are equal in magnitude but point in opposite directions so they cancel out each other effect and we get net dipole moment zero.
On the other hand sulfur dioxide (SO2) exhibits a dipole moment because unlike CO2 molecule SO2 is not a linear molecule because of the presence of lone pair on Sulfur (S) atom , the geometry of SO2 is bent. This bent orientation of the oxygen's with respect to the sulfur results in the uneven distribution of positive and negative charges between the sulfur atom and the two oxygen atoms in the diagonal-shaped sulfur dioxide molecule. So the dipoles are not equal in magnitude and they do not cancel out and SO2 molecule exhibit a net dipole moment.
NOTE: If the molecule is linear, the dipoles are equal and exactly opposite in direction, so like a perfectly equal tug-of-war, they cancel each other out, and there is no net dipole in the molecule.
CO2 (linear molecule) = The dipoles are equal and exactly opposite in direction. They cancel each other out, and there is no net dipole in the molecule.
SO2 ( bent shape not linear) = Their is an uneven distribution of positive and negative charges between the sulfur atom and the two oxygen atoms. Dipoles are not equal in magnitude and they do not cancel out and SO2 molecule exhibit a net dipole moment.