Charge-dependent azimuthal particle correlations with respect to the second-order event plane in p-Pb and PbPb collisions at a nucleon-nucleon center-of-mass energy of 5.02 TeV have been studied with the CMS experiment at the LHC. The measurement is performed with a three-particle correlation technique, using two particles with the same or opposite charge within the pseudorapidity range |η|<2.4, and a third particle measured in the hadron forward calorimeters (4.4