The paper addresses an optimal control problem for a perturbed sweeping process of the rate-independent hysteresis type described by a controlled "play-and stop" operator with separately controlled perturbations. This problem can be reduced to dynamic optimization of a state-constrained unbounded differential inclusion with highly irregular data that cannot be treated by means of known results in optimal control theory for differential inclusions. We develop the method of discrete approximations, which allows us to adequately replace the original optimal control problem by a sequence of well-posed finite-dimensional optimization problems whose optimal solutions strongly converge to that of the controlled perturbed sweeping process. To solve the discretized control systems, we derive effective necessary optimality conditions by using second-order generalized differential tools of variational analysis that explicitly calculated in terms of the given problem data.