We present photometric observations of the field around the optical counterparts of high-mass X-ray binaries. Our aim is to study the long-term photometric variability in correlation with their X-ray activity and derive a set of secondary standard stars that can be used for time series analysis. We find that the donors in Be/X-ray binaries exhibit larger amplitude changes in the magnitudes and colours than those hosting a supergiant companion. The amplitude of variability increases with wavelength in Be/X-ray binaries and remains fairly constant in supergiant systems. When time scales of years are considered, a good correlation between the X-ray and optical variability is observed. The X-rays cease when optical brightness decreases. These results reflect the fact that the circumstellar disk in Be/X-ray binaries is the main source of both optical and X-ray variability. We also derive the colour excess, E(B-V), selecting data at times when the contribution of the circumstellar disk was supposed to be at minimum, and we revisit the distance estimates.