Optimal control in space-time (t,x,y) with BFGS

Hello,
I would like to know where I should call BFGS, since my optimal control for parameter (t,x,y) is it inside the time loop that I define BFGS ?

Thanks