Electric infrared patio heaters can be used under a roof, provided the manufacturer's clearance distances are carefully followed. See the individual products for the clearance distances.
Gas heaters require good ventilation to enable them to be run safely and therefore careful consideration needs to be given to the airflows in and around any gas heater should they be used under a roof. Gas heaters also produce heat which rises and the heat may cause damage to a roof or ceiling. Ensure you carefully assess the manufactures guidelines for both the heater and the roofing materials.