Obesity and diabetes are diseases that are increasing every year in the world and their control is an important problem faced by health systems. In this work, we present an optimal control problem based on a model for overweight and obesity and its impact on the diagnosis of diabetes using fractional order derivatives in the Caputo sense. The controls are defined with the objective of controlling the evolution of an individual with normal weight to overweight and that overweight leads to chronic obesity. We show the existence of optimal control using Pontryagin’s maximum principle. We perform a study of the global sensitivity for the model using Sobol's index of first, second and total order using the polynomial chaos expansion (PCE) with two techniques, ordinary least squares (OLS) and least angle regression (LAR) to find the polynomial coefficients, and two sampling methods, Monte Carlo and Sobol. With the obtained results, we find that among the parameters with the greatest influence are those we used in the definition of the control system. We have that the best results are achieved when we activate the three controls. However, when we only activate two controls, it shows better results in preventing a person with normal weight from becoming overweight by controlling weight gain due to social pressure and the evolution from overweight to obesity. All strategies significantly reduce the number of cases diagnosed with diabetes over time.