The difference is that the centre of mass is the weighted average of location with respect to mass, whereas the centre of gravity is the weighted average of location with respect to mass times local gg. If gg cannot be assumed constant over the whole of the body (perhaps because the body is very tall), they might (and generally will) have different values.
Centre of mass & gravity coincides until they have unifrom gravitational field. The time uniform gravitational field is lost we rather consider centre of mass than centre of gravity