The energy consumption of a sensor network is significantly affected by task assignments to the nodes in the network. In this paper, a task assignment method to extend the lifetime of wireless sensor networks is presented that exploits task decomposition and transformation. The task assignment is formulated as an optimization problem by providing a cost function incorporating the task decomposition and transformation at the same time. To show the validity and feasibility of our proposed method, we implement a task assignment framework using a simulated annealing approach. The simulation results show that optimal assignments and task decomposition can significantly improve the lifetime of wireless sensor networks.