Speeding up and slowing down the relaxation of a qubit by optimal control