This paper addresses the problem of solving a constrained optimal control for a general single-input single output linear time varying system by means of an unconstrained method. The exposed methodology uses a penalty function approach, commonly considered in finite dimensional optimization problem, and extended here it to the considered infinite dimensional (functional optimization) case. The main novelty is that both the bounds on the control variable and on a freely chosen output variable are considered and studied theoretically. It is shown that a relatively simple and constructive choice of penalty functions allows to completely alleviate the usual difficulties of handling such constraints in optimal control. An illustrative example is provided to show the potential of the method.