This paper presents a new approach for tuning PID controller parameters in the control of nonlinear systems. The design is based on optimal tracking of step response for nonlinear systems. The problem is first restated as a non linear optimal control infinite horizon problem, then with a suitable change of variable, the time interval is transferred to the finite horizon [0 1). This change of variable, poses a time varying problem. This problem is then transferred to measure space, and it is shown that an optimal measure must be determined which is equivalent to a linear programming problem with infinite dimension. Then, using finite horizon approximations, the optimal control law as piece wise constant function is determined. Finally, PID controller parameters are Determined using the optimal control law. Simulations are provided to show the effectiveness of the proposed methodology.