To prevent food from sticking to the surface of aluminum foil when cooking, you can lightly coat the foil with a thin layer of cooking oil or non-stick spray before placing the food on it. This creates a barrier between the food and the foil. Additionally, ensure the foil is not torn or damaged, as this can cause food to stick. Using a heavier gauge foil can also help reduce sticking. Finally, avoid overcrowding the food on the foil, as this can cause it to stick due to uneven cooking and steam build-up.