In this paper, boundary value problems of fractional order are converted into an optimal control problems. Then an approximate solution is constructed from translations and dilations of a B-spline function such that the exact boundary conditions are satisfied. The fractional differential operators are taken in the Riemann-Liouville and Caputo sense. Several example are given and the optimal errors are obtained for the sake of comparison. The obtained results are shown that the technique introduced here is accurate and easy to apply.