The main purpose of this paper is to provide an efficient method for solving some types of fractional optimal control problems governed by integro-differential and differential equations, and because finding the analytical solutions to these problems is usually difficult, a numerical method is proposed. In this study, the fractional-order Bernoulli functions (F-BFs) are applied as basis functions and a new operational matrix of fractional integration is constructed for these functions. In the first step, the problem is transformed into an equivalent variational problem. Then the F-BFs, the constructed operational matrix, the Gauss quadrature formula, and necessary conditions for optimization are used to convert the problem into a system of algebraic equations. Finally, with the aid of Newton’s iterative method, the system of algebraic equations is solved and the approximate solution of the problem is obtained. Several numerical examples have been analysed for illustrating the efficiency and accuracy of the proposed method, and the results have been compared with the exact solutions and the results of other methods. The results show that the method provides accurate solutions.