Milk curdles when lemon juice is added to it because the acid in the lemon juice lowers the pH of the milk and causes its particles to solidify and expand. Because these particles are repelled by the acid, they rise to the top to get as far away from it as possible, separating the solid milk curds from the liquid whey.
This reaction between milk and lemon juice occurs much faster when the milk is heated to a temperature between 86 and 104 degrees Fahrenheit, where the curdling happens almost instantly. When milk is cold, the reaction takes a lot longer, making it possible to add cold milk and lemon juice to a recipe without curdling when this is desired in baking or other cooking.
While curdling in many recipes can signal a problem, in some processes such as cheese-making, curdling is desired to separate the curds from the whey. Ricotta cheese and brie cheese are both made using a similar process with lactic acid to create the separation of curds and whey. The creation of cottage cheese, farmer's cheese, queso blanco and paneer also employs this same method of curdling, although instead of lemon juice, bacteria, rennet and lime juice play a role in their production.