In software testing, fault detection and removal process is one of the key elements for quality assurance of the software. In the last three decades, several software reliability growth models were developed for detection and correction of faults. These models were developed under strictly static assumptions. This paper is to investigate an optimal resource allocation plan for fault detection and removal process of software to minimize cost during testing and operational phase under dynamic condition. For this the authors have developed a mathematical model for fault detection and removal process and Pontryagain's maximum principle is applied for solving the model.