Optical rebrightenings in the afterglows of some gamma-ray bursts (GRBs) are unexpected within the framework of the simple external shock model. While it has been suggested that the central engines of some GRBs are newly born magnetars, we aim to relate the behaviors of magnetars to the optical rebrightenings. A newly born magnetar will lose its rotational energy in the form of Poynting-flux, which may be converted into a wind of electron-positron pairs through some magnetic dissipation processes. As proposed by Dai, this wind will catch up with the GRB outflow and a long-lasting reverse shock (RS) would form. By applying this scenario to GRB afterglows, we find that the RS propagating back into the electron-positron wind can lead to an observable optical rebrightening and a simultaneous X-ray plateau (or X-ray shallow decay). In our study, we select four GRBs (i.e., GRB 080413B, GRB 090426, GRB 091029, and GRB 100814A), of which the optical afterglows are well observed and show clear rebrightenings. We find that they can be well interpreted. In our scenario, the spin-down timescale of the magnetar should be slightly smaller than the peak time of the rebrightening, which can provide a clue to the characteristics of the magnetar.