The center of gravity is based on weight, whereas the center of mass is based on mass. So, when the gravitational field across an object is uniform, the two are identical. However, when the object enters a spatially-varying gravitational field, the COG will move closer to regions of the object in a stronger field, whereas the COM is unmoved.
More practically, the COG is the point over which the object can be perfectly balanced; the net torque due to gravity about that point is zero. In contrast, the COM is the average location of the mass distribution. If the object were given some angular momentum, it would spin about the COM.