The production and purification of ethanol from sorghum lignocellulosic materials by a two stages process was modeled and optimized in the present work. The process involves a first stage for hydrolyzing sweet sorghum bagasse and simultaneously fermenting the generated sugars and a second stage for the separation of ethanol from the filtered culture. Kinetic and distillation equations were embedded into macroscopic balances in order to derive a mathematical model used to solve a two-stage optimal control problem. The aim was to maximize the productivity of the process by optimally managing the controlled flows and by optimally fixing the switching time between the fermentation phase and the separation phase.