What you are essentially dealing with is a phase change, in this particular case the freezing of liquid milk. The driving force for any phase change is heat, or in other words, the addition or removal of heat.
In order to get a substance from liquid to solid, you must remove energy in the form of heat from it; the exact opposite takes place when you go from solid to liquid, heat must be provided to the substance.
So, in order to change the phase of milk, you must remove heat from it. Usually, this is done by placing the milk in direct contact with ice. From this point on, heat will flow from the milk into the colder ice surroudings.
After enough time, the energy of the milk will decrease sufficiently for the liquid to freeze.
Thermodinamically, the process can be described like this:
Cooling the milk to 0 degrees Celsius
Freezing the milk
Cooling the frozen milk to whatever temperature the freezer is set on
All these three heat values are negative, which confirms a decrease in energy and that heat is being removed from the liquid milk.