Wireless nodes are one of the main components in different applications that are offered in a smart city. These wireless nodes are responsible to execute multiple tasks with different priority levels. As the wireless nodes have limited processing capacity, they offload their tasks to cloud servers if the number of tasks exceeds their task processing capacity. Executing these tasks from remotely placed cloud servers causes a significant delay which is not required in sensitive task applications. This execution delay is reduced by placing fog computing nodes near these application nodes. A fog node has limited processing capacity and is sometimes unable to execute all the requested tasks. In this work, an optimal task offloading scheme that comprises two algorithms is proposed for the fog nodes to optimally execute the time-sensitive offloaded tasks. The first algorithm describes the task processing criteria for local computation of tasks at the fog nodes and remote computation at the cloud server. The second algorithm allows fog nodes to optimally scrutinize the most sensitive tasks within their task capacity. The results show that the proposed task execution scheme significantly reduces the execution time and most of the time-sensitive tasks are executed.