Achieving energy efficiency is always a primary concern for fog-architecture-based Internet of Things (IoT) applications. As the IoT devices are typically of small sizes and powered by battery energy, it is essential to address the energy consumption at all levels from the circuit to the system. Two of the promising solutions at circuit and system levels are approximate computing and energy-aware task allocation, respectively. However, the existing task allocation approaches are designed without considering the aspect of approximate computing. In this work, we fill this gap and aim to maximize the network lifetime subject to the accuracy requirements of the applications. By considering both the approximate computing and task allocation simultaneously, a nonlinear problem is obtained to allocate the tasks for the devices (fog nodes and IoT end devices) and to select the corresponding execution modes (tasks in approximate or exact modes). To efficiently solve this problem, a centralized algorithm is first proposed by transferring the above nonlinear problem as a linear programming (LP) problem. As executing the centralized algorithm is a challenge for the resource-limited IoT devices, this work further proposes an optimal distributed algorithm based on Dantzig–Wolfe decomposition to solve the problem of tasks distribution and execution modes selection. The centralized large-scaled LP problem is decomposed into small-scaled subproblems, which can be efficiently solved by each IoT device. The proposed algorithms are tested by extensive simulations. The results demonstrate that the distributed algorithm achieves the same results as the centralized algorithm, and both of them significantly outperform the previous approaches.