Keep your computer updated with the latest software to minimise any webcam security risk. You can also use a firewall to lock down your network and keep hackers at bay.
Make sure that your Wi-Fi connection is secured as well. Create a name and password that are difficult to guess and can't be easily associated with you.
Never click suspicious links sent over to you as hackers can trick you into installing malicious software using shady links to control your computer, including your webcam.
Many webcams also include privacy shutters – essentially plastic or metal shutters that close the webcam's "eye" when not in use. That can be a valuable security measure in itself – and of course, you can always go lo-fi with that approach by folding a little paper or similar over the front of your webcam when you don't need it.