With the rapid development in the area of Internet of Things (IoT), the number of delay-sensitive and power-hungry IoT applications has dramatically increased over the past few years. Mobile edge computing (MEC) has become as an effective computing model for meeting the IoT applications requirements. However, the resource-constraint nature of IoT devices, different characteristics of IoT tasks, and heterogeneity of edge cloud servers (ECSs) makes the task offloading problem as a fundamental challenge in MEC systems. Motivated by this, in this research, we propose a deadline-aware and energy-efficient computation offloading algorithm, named DECO, for scheduling and processing the generated tasks from the IoT devices. The proposed algorithm jointly takes into account the deadline requirement of the tasks and the energy consumption of the IoT devices in the local decision-making process. Also, it considers the priority of the tasks and heterogeneity of ECSs for the task-node mapping process. The extensive simulation results under various performance metrics confirm that the proposed algorithm can improve the deadline satisfaction ratio up to 58% and average response time up to 18% compared to the state-of-the-art, while the amount of increase in the total energy consumption of IoT devices is less than 12%.