Several economies around the world are using second-generation (2G) ethanol produced from agricultural residues, like sugarcane straw and bagasse, as a sustainable solution to replace petroleum products. Since first-generation (1G) ethanol uses the sugars of sugarcane, an integrated 1G–2G production would enable the production of more ethanol from the same amount of sugarcane without leading to increased use of arable land. The ethanol production process is complex, involving different high-energy consumption operations such as evaporation and distillation. The economic competitiveness of this process depends heavily on the amount of thermal and electrical energy produced using sugarcane straw and bagasse as input. Thus, the objective of this study was to use the mean-variance methodology to determine the optimal allocation of residual sugarcane biomass between 2G ethanol and bioelectricity productions, with simultaneous objectives of maximizing the return and minimizing the risk for investors of this sector. In this paper, four scenarios are analyzed. The first one is the base scenario that represents the current state of production costs and investments. scenarios 2, 3, and 4 considered four cuts of 10%, 20%, and 40% in the production cost of ethanol 2G, respectively. The results show the optimum biomass allocations and the growth rates of returns as a function of risk growth. It can be concluded that from scenario 4, the production of 2G ethanol becomes financially advantageous for the investor, presenting greater returns with smaller risks.