This paper presents a new approach to path following control design for an autonomous underwater vehicle (AUV). A NARMAX model of the AUV is derived first and then its parameters are adapted online using the recursive extended least square algorithm. An adaptive Propotional-Integral-Derivative (PID) controller is developed using the derived parameters to accomplish the path following task of an AUV. The gain parameters of the PID controller are tuned using an inverse optimal control technique, which alleviates the problem of solving Hamilton-Jacobian equation and also satisfies an error cost function. Simulation studies were pursued to verify the efficacy of the proposed control algorithm. From the obtained results, it is envisaged that the proposed NARMAX model-based self-tuning adaptive PID control provides good path following performance even in the presence of uncertainty arising due to ocean current or hydrodynamic parameter.