The Pontryagin maximum principle and transversality conditions for a class of optimal control problems with infinite time horizons