Theories on the origin of magnetic fields in massive stars remain poorly developed, because the properties of their magnetic field as function of stellar parameters could not yet be investigated. To investigate whether magnetic fields in massive stars are ubiquitous or appear only in stars with a specific spectral classification, certain ages, or in a special environment, we acquired 67 new spectropolarimetric observations for 30 massive stars. Among the observed sample, roughly one third of the stars are probable members of clusters at different ages, whereas the remaining stars are field stars not known to belong to any cluster or association. Spectropolarimetric observations were obtained during four different nights using the low-resolution spectropolarimetric mode of FORS2 (FOcal Reducer low dispersion Spectrograph) mounted on the 8-m Antu telescope of the VLT. Furthermore, we present a number of follow-up observations carried out with the high-resolution spectropolarimeters SOFIN mounted at the Nordic Optical Telescope (NOT) and HARPS mounted at the ESO 3.6m between 2008 and 2011. To assess the membership in open clusters and associations, we used astrometric catalogues with the highest quality kinematic and photometric data currently available. The presence of a magnetic field is confirmed in nine stars previously observed with FORS1/2: HD36879, HD47839, CPD-282561, CPD-472963, HD93843, HD148937, HD149757, HD328856, and HD164794. New magnetic field detections at a significance level of at least 3sigma were achieved in five stars: HD92206c, HD93521, HD93632, CPD-468221, and HD157857. Among the stars with a detected magnetic field, five stars belong to open clusters with high membership probability. According to previous kinematic studies, five magnetic O-type stars in our sample are candidate runaway stars.