An optimal control problem with a time-parameter is considered. The functional to be optimized includes the maximum over time-horizon reached by a function of the state variable, and so an L-term. In addition to the classical control function, the time at which this maximum is reached is considered as a free parameter. The problem couples the behavior of the state and the control, with this time-parameter. A change of variable is introduced to derive first and second-order optimality conditions. This allows the implementation of a Newton method. Numerical simulations are developed, for selected ordinary differential equations and a partial differential equation, which illustrate the influence of the additional parameter and the original motivation.