Most plagiarism happens accidentally, through poor note taking and not understanding how to reference. Here's how you can avoid this:
Take detailed notes as you research
When reading a source, anytime you note down something word-for-word, immediately place it in quotation marks so you know it's a quotation. Make sure you also note the original source and what page you found it on. This will make giving a citation much easier, and save you panicking at the last minute.
Keep your own thoughts and ideas separate when making notes
If you mix-up your own comments and ideas when making notes on a source, it may be easy to accidentally assume that the ideas from that source are your own too! Be very careful if you cut-and-paste from online resources. Keep your own thoughts on a separate page, or colour-code to keep it clear.
Make sure you understand how to paraphrase correctly
Paraphrasing is restating someone else's ideas in your own words. Changing a few words of the original sentences does not make your writing a legitimate paraphrase. You must change both the words and the sentence structure of the original, without changing the meaning. You must also provide a citation to the source that you have paraphrased.
Make sure you understand how to include citations
Citations must be included any time you quote, paraphrase or summarise from a source, as well as when you refer to ideas, research, data or statistics found in other sources. It should be apparent which piece of information a citation is referring to, and your citation should usually appear in the same sentence where you included the quote, paraphrase or summarise. Check how to give citations here.
If in doubt, provide a citation
If you're not sure if you need to provide a citation, it's always better to have one than not. If you're including a long paraphrase or mixing your own ideas with a source, it's good to restate the citation so it's clear to your readers where those ideas originated from.