To prevent food from sticking to the surface of aluminum foil when cooking, you can use a few techniques. First, lightly coat the foil with a thin layer of oil or non-stick cooking spray. This creates a barrier that food won't stick to. Second, ensure that the foil is smooth and wrinkle-free; any rough spots can cause food to stick. Additionally, avoid overfilling the foil as this can lead to uneven cooking and sticking. Finally, consider using parchment paper or a silicone baking mat instead of foil for some foods, as they can provide a non-stick surface without the risk of aluminum foil tearing or food sticking.