If you're yet to pass your driving test, you'll need to take a compulsory basic training (CBT) course. As Gov.UK explains, this training makes sure you can ride safely on your own while you practice for your full moped or motorcycle test.
After you've completed your CBT, you can ride a moped if you're 16 or over, or a motorcycle up to 125cc with a max power output of 11kW if you're 17 or over. You must display L plates and pass your full moped or motorcycle test within two years - or take the entire CBT again.
You don't need to undergo CBT if you want to ride a moped and you passed your driving test before 1 February 2001, or you want to ride a motorcycle and have a full moped licence from passing a moped test since 1 December 1990. That same goes if you hold a full motorcycle licence for one category and want to change to another.
You'll also need to tax and insure your moped before you can take it out.