This study is devoted to introducing a computational technique based on Bernstein polynomials to solve variable order fractional optimal control problems (VO-FOCPs). This class of problems generated by dynamical systems describe with variable order fractional derivatives in the Caputo sense. In the proposed method, the Bernstein operational matrix of the fractional variable-order derivatives will be derived. Then, this matrix is used to obtain an approximate solution to mentioned problems. With the use of Gauss-Legendre quadrature rule and the mentioned operational matrix, the considered VO-FOCPs are reduced to a system of equations that are solved to get approximate solutions. The obtained results show the accuracy of the numerical technique.