We report on a NIR, optical and X-ray campaign performed in 2017 with the XMM-Newton and Swift satellites and the VLT/HAWK-I instrument on the transitional MSP PSR J1023+0038. NIR observations were performed in fast-photometric mode in order to detect any fast variation of the flux and correlate them with the optical and X-ray light curves. The optical curve shows the typical sinusoidal modulation at the orbital period (4.75hr). No flaring or flickering is found in the optical, neither signs of transitions between active and passive states. On the contrary, the NIR curve displays a bimodal behaviour, showing strong flares in the first part of the curve, and an almost flat trend in the rest. The X-ray curves show a few low/high mode transitions, but no flaring activity. One of the low/high mode transition is found to happen at the same time as the emission of an infrared flare. This can be interpreted as the emission of a jet: the NIR flare could be due to the evolving spectrum of the jet, which possesses a break frequency that moves from higher (NIR) to lower (radio) frequencies after the launching, that has to happen at the low/high mode transition. We also present the cross correlation function between the optical and near infrared curves. Due to the bimodality of the NIR curve, we divided it in two parts (flaring and quiet). While the CCF of the quiet part is found to be flat, the one referring to the flaring part shows a narrow peak at ~10s, which indicates a delay of the NIR emission with respect to the optical. This lag can be interpreted as reprocessing of the optical emission at the light cylinder radius with a stream of matter spiraling around the system due to a phase of radio-ejection. This strongly supports a different origin of the NIR flares observed for PSR J1023+0038 with respect to the optical and X-ray flaring activity reported in other works on the same source.