1It is very wrong. You CANNOT have a cord passing through siding, walls, or any other finished structure/surface. For both code and safety reasons.
The receptacle MUST be outside. If it is close to the heat tape you'll just need to coil the cord up.
National Electrical Code 2011
Chapter 4 Equipment for General Use
Article 400 Flexible Cords and Cables
I. General
400.8 Uses Not Permitted. Unless specifically permitted in 400.7, flexible cords and cables
shall not be used for the following:
(1) As a substitute for the fixed wiring of a structure
(2) Where run through holes in walls, structural ceilings, suspended
ceilings, dropped ceilings, or floors
(3) Where run through doorways, windows, or similar openings
(4) Where attached to building surfaces
Exception to (4): Flexible cord and cable shall be permitted to be
attached to building surfaces in accordance with the provisions of
368.56(B).
(5) Where concealed by walls, floors, or ceilings or located above
suspended or dropped ceilings
(6) Where installed in raceways, except as otherwise permitted in this
Code
(7) Where subject to physical damage
In a perfect world, with perfect electronics, there would be no need for a grounding conductor. It's there to deal with imperfections. The most likely case for a ground fault in this installation would be if the black conductor lost some insulation and shorted itself against the frame of the fan. In such a situation, the casing could become electrified, and a grounded person, touching the fan body could receive a shock.
If it were properly grounded, you'd get a short circuit to the ground wire, and the breaker would trip.
However, the fan is mounted to the ceiling, and the possibility of someone touching it is low. (Unlike, for example, the frame of a fridge or stove, where human contact is part of normal operation.)
So, Is it safe? Quite likely. For added safety, turn the wall switch off when changing bulbs. Is it to code? No. -- Unless, as others have suggested in comments, the mounting box is grounded on the other side.
You can however, locate the breaker, and replace it with a Ground Fault Interrupt breaker, which would trip should a ground fault occur. This isn't something you should do yourself unless you have experience working in the panel.
Another possibility, if your switch happens to be chained off of an outlet, which is quite possible, depending on the routing of the wiring on that circuit, is to replace the outlet with a GFCI outlet, and wire the switch to the load side of it.
Best Answer
That is 100% a code violation. A flexible cord CANNOT be used as a substitute for permanent wiring. The means of disconnect, or service disconnect, is the switch outside. They should have simply hard wired with cable to the receptacle box, or better yet, run a circuit to the fan, not for the added load, but to keep the fan isolated from other loads.