On-line control and optimization can improve the efficiency of fuel cell systems, whilst simultaneously ensuring that the operation remains within a safe region. Also, fuel cells are subject to frequent variations in their power demand. This paper investigates the real-time optimization (RTO) of a solid oxide fuel cell (SOFC) stack. An optimization problem maximizing the efficiency subject to operating constraints is defined. Due to inevitable model inaccuracies, the open-loop implementation of optimal inputs evaluated off-line may be suboptimal, or worse, infeasible. Infeasibility can be avoided by controlling the constrained quantities. However, the constraints that determine optimal operation might switch with varying power demand, thus requiring a change in the regulator structure. In this paper, a control strategy that can handle plant-model mismatch and changing constraints in the face of varying power demand is presented and illustrated. The strategy consists in the integration of RTO and model predictive control (MPC). A lumped model of the SOFC is utilized at the RTO level. The measurements are not used to re-estimate the parameters of the SOFC model at different operating points, but to simply adapt the constraints in the optimization problem. The optimal solution generated by RTO is implemented using MPC that uses a step-response model in this case. Simulation results show that near-optimality can be obtained, and constraints are respected despite model inaccuracies and large variations in the power demand.