Microorganisms such as bacteria and many eukaryotic cells propel themselves with hair-like structures known as flagella, which can exhibit a variety of structures and movement patterns. For example, bacterial flagella are helically shaped and driven at their bases by a reversible rotary engine, which rotates the attached flagellum to give a motion similar to that of a corkscrew. In contrast, eukaryotic cells use flagella that resemble elastic rods and exhibit a beating motion: internally generated stresses give rise to a series of bends that propagate towards the tip. In contrast to this variety of swimming strategies encountered in nature, a controlled swimming motion of artificial micrometre-sized structures has not yet been realized. Here we show that a linear chain of colloidal magnetic particles linked by DNA and attached to a red blood cell can act as a flexible artificial flagellum. The filament aligns with an external uniform magnetic field and is readily actuated by oscillating a transverse field. We find that the actuation induces a beating pattern that propels the structure, and that the external fields can be adjusted to control the velocity and the direction of motion.