what is the main difference between lava and magma?

magma is a mixture of molten or semi-molten rock, volatiles and solids that is found beneath the surface of the Earth, and is expected to exist on other terrestrial planets.

lava is the molten rock expelled by a volcano during an eruption and the resulting rock after solidification and cooling.

basically it's called magma when it's in the volcano/beneath surface of earth but once a volcano erupts the magma that flows out is now called lava.