Decide on the poetic meter you want to use. Each meter has its own rules. For instance, the "ballad meter" consists of alternating lines of four and three iambic feet. This pattern is often used in songs, such as "Amazing Grace."
Familiarize yourself with the meter you've chosen. Practice writing in it. Eventually, you'll find that it becomes natural and familiar.
Mark the stressed syllables in your poem as you write. The most common symbol for a stressed syllable is a small tick or apostrophe over the stress. Consider this line from "The Eve of St Agnes" by John Keats: "A casement high and triple-arch'd there was." The line can be diagrammed as follows: "A 'case / ment 'high / and 'trip / le 'arch'd / there 'was." The regular placement of the stresses is clear. Leave these marks out of the final poem; they're only a tool to help you practice.
Allow yourself some variation. Poetic meter can vary when the poem demands it, often at the end of a line. Meter is meant to be a tool to aid creativity, not restrict it.