The center of mass is the position where all the mass of the body acts whereas center of gravity is where the all the gravity in a body acts. If gravitational field is uniform across an object then the center of mass and center of gravity are same . But when the condition changes they also changes. Also center of gravity is based on weight while center of mass is based on mass. When the body enters a spatially varying gravitational field the COG moves towards the portion where field is high but the COM stays unchanged. The object can be perfectly balanced over COG. COM tells you about the elemental properties of a body while COG tells you about action of gravitational field in a body. While designing a body in the ground both COG and COM are taken same but when designing something like a spaceship both are taken different.