Code Requirements
Safe Distance
If an electrical cord is plugged into an outlet close to a door, it could cause damage by striking it. Additionally, it could become entangled in the door and be yanked from the outlet. It is also possible for an electrical cord to get pinched between the door and the jam.
Bottom Line
Installing an electrical outlet is as much about convenience as it is need. If there is no practical location other than behind a door, then you have little choice. Weigh your willingness to bear the consequences and risks against the convenience of the outlet’s location.