In this paper, we use the operational matrices (OMs) and collocation method (CM) to obtain a numerical solution for a class of variable-order differential equations (VO-DEs). The fractional derivatives and the VO-derivatives are in the Caputo sense. The operational matrices are computed based on the Hosoya polynomials (HPs) of simple paths. Firstly, we assume the unknown function as a finite series by using the Hosoya polynomials as the basis functions. To obtain the unknown coefficients of this approximation, we computed the operational matrices of all terms of the main equations. Then, by using the operational matrix and collocation points, the governing equations are converted to a set of algebraic equations. Finally, an approximate solution is obtained by solving those algebraic equations.