A common approach is to use a
MOSFET or transistor. This MOSFET/transistor is then controlled using the
pwmout command to set the speed.
If it is desired to be able to make the motor rotate the other way then a H-bridge can be used. A H-bridge can be made from 4 individual transistors or a motor driver like the
L293D can be used.
Remember that the speed of a DC motor isn't regulated - if you need to regulate the speed then a regulated motor like a stepper or three-phase motor can be used or you can use a rotary encoder connected to the DC motor to measure the speed then adjust the PWM duty cycle to reach the desired speed.