Extreme and rare events are nowadays the object of intensive research. Rogue waves are extreme waves that appear suddenly in many natural systems, even in apparently calm situations. Here we study numerically the rogue wave dynamics in an optically injected semiconductor laser with external periodic forcing that is implemented via direct modulation of the laser pump current. In the region of optical injection parameters where the laser intensity is chaotic and occasional ultrahigh pulses occur, our aim is to control the system by applying a weak modulation. We find that for an adequate range of frequency and amplitude parameters, the modulation can completely suppress the extreme pulses. We also show that the interplay between modulation and an external source of noise can significantly modify their probability of occurrence. These results can motivate a range of experimental and theoretical investigations in other natural systems.