Near infrared (IR) studies of Cepheid variables in the LMC take advantage of the reduced light curve amplitude and metallicity dependence at these wavelengths. This work presents such photometry for two young clusters known to contain sizeable Cepheid populations: NGC 1866 and NGC 2031. Our goal is to determine light curves and period-luminosity (PL) relations in the near-IR, to assess the similarity between cluster and field pulsators, and to examine the predictive capability of current pulsation models. The light curves are obtained from multiwavelength broadband J,H,Ks photometry of Cepheids in both clusters, with periods previously established from optical photometry. Mean magnitudes for the Cepheids are used to construct PL relations in the near-IR. The properties in the PL planes are compared with the behavior of field Cepheids in the LMC and with the predictions of recent pulsational models, both canonical and overluminous. Cluster and field Cepheids are homogeneous and the inclusion of the cluster Cepheids in the field sample extends nicely the PL relation. The slope of the PL relation is constant over the whole period range and does not show -- at least in the adopted IR bands -- the break in slope at P ~ 10 d reported by some authors. A comparison with the predictions of pulsation models allows an estimate for the distance moduli of NGC 1866 and NGC 2031. The two clusters are found to lie at essentially the same distance. Fitting of theoretical models to the data gives, for the K filter, (m-M)_0 = 18.62+-0.10 if canonical models are used and (m-M)_0 = 18.42+-0.10 if overluminous models are used. On the basis of this result, some considerations on the relationship between the clusters and the internal structure of the LMC are presented.