During the formation of CaCl2, calcium loses 2 electrons thereby getting a charge of +2 while each atom of chlorine gains 1 electron, thereby getting a charge of -1.
The oxidation number of Ca is the charge attained by it during the formation of CaCl2.