Aiming at the task allocation in multi-target tracking of wireless sensor networks, the discrete particle swarm optimization based on nearest-neighbor is presented to reduce the communication energy consumption between nodes. First, task allocation is initialized with nearest neighbor algorithm. Then the fitness function is compared through change task allocation matrix to achieve task allocation. Simulation results show that task allocation based on particle swarm optimization can effectively reduce communication energy consumption than nearest neighbor optimization in the relatively sparse nodes coverage.