The increasing use of Internet of Things (IoT) devices generates a greater demand for data transfers and puts increased pressure on networks. Additionally, connectivity to cloud services can be costly and inefficient. Fog computing provides resources in proximity to user devices to overcome these drawbacks. However, optimisation of quality of service (QoS) in IoT applications and the management of fog resources are becoming challenging problems. This paper describes a dynamic online offloading scheme in vehicular traffic applications that require execution of delay-sensitive tasks. This paper proposes a combination of two algorithms: dynamic task scheduling (DTS) and dynamic energy control (DEC) that aim to minimise overall delay, enhance throughput of user tasks and minimise energy consumption at the fog layer while maximising the use of resource-constrained fog nodes. Compared to other schemes, our experimental results show that these algorithms can reduce the delay by up to 80.79% and reduce energy consumption by up to 66.39% in fog nodes. Additionally, this approach enhances task execution throughput by 40.88%.