Optimal protocols for driven quantum systems