According to the F.D.A., pies that contain dairy products should be refrigerated within two hours of baking, while pies that don’t contain dairy products may last for up to two days at room temperature.