It is generally recommended to transfer leftovers to proper food storage containers and refrigerate them within two hours of cooking to prevent bacterial growth.