This paper provides a new numerical scheme with the help of discrete Krawtchouk polynomials (DKPs), the Ritz method, and the two-dimensional (2D) Gauss-Legendre quadrature rule for dealing with two-dimensional variable-order (VO) fractional optimal control problems. For this aim, we construct the derivative operational matrices of DKPs. Also, we impose the conditions into the approximation of state and control functions. Then, we expand the functions in the problem given DKPs and operational matrices. Meanwhile, DKPs and the 2D Gauss-Legendre quadrature rule evaluate the performance index function. According to the numerical algorithm process, the proposed problem is reduced to a system of algebraic equations. The chosen polynomial as basis functions and the Ritz method provide a powerful and flexible scheme. Also, we discuss the error of the VO-fractional derivative of the approximate solution and performance index. At last, we include several illustrative examples to indicate the validity and applicability of the present technique.