Fractional optimal control problem for ordinary differential equation in weighted Lebesgue spaces