On the well posedness of some optimal control problems