I kinda understood how field-oriented control works but I have a question in my mind. How am I gonna control the speed of the motor? With which variable am I gonna be able to do that? For example, in a single-phase motor I just control the duty cycle of PWM. But in FOC I do not get which part I am gonna play with.
FOC is inherently a current controller, since the intention of FOC is to align the current vector with the magnetic field (this is true even with MTPA since the change in inductance that gives reluctance torque corresponds to a changing magnetic field).
So your input to the true FOC part is the Tref in the diagram above.
You have a speed controller external to the FOC which changes the Tref depending on the measured speed error.
I think the presence of wref going into the MTPA block in your diagram is an error. Speed is not required to calculate the MTPA Id and Iq outputs.