In this paper, we use a dynamic programming formulation to address a class of multi-agent task assignment problems that arise in the study of fuel optimal control of multiple agents. The fuel optimal multi-agent control is highly relevant to multiple spacecraft formation reconfiguration, an area of intense current research activity. Based on the recurrence relation derived from the celebrated principle of optimality, we develop an algorithm with a distributed computational architecture for the global optimal task assignment. In addition, we propose a communication protocol to facilitate decentralized decision making among agents. Illustrative studies are included to demonstrate the efficacy of the proposed multi-agent optimal task assignment algorithm.