The centre of mass is always the same.
The centre of gravity depends on gravity's pull. If it pulls equally everywhere, then this pull as well averages out to be in the centre of mass.
But imagine having a very tall uniform object. A beam standing on the surface and reaching 300 km outwards i.e. The bottom is closer to earth where gravity is stronger, while there is less gravitational pull in the far end. The result is an averaged gravitational pull closer to the Earth surface.
The centre of mass is still in the very middle of the beam, but the centre of gravity is not anymore.
From the comment, let me add the note that the centre of mass regards one object and not necessarily a whole system. When Earth pulls in the beam in my example, then that gravitational force is an external force. The beam is the system in my example, not including Earth.