It is easiest to first decide where the cadances are, and then from doing that you can figure out which key that phrase ends in. Then look at the final three or four notes of the phrase to find a pivot chord. This is essential for modulating smoothly between the two keys within the phrase.
If you're really stuck, make sure you rely on the primary chords I, IV and V, and use different inversions as well as root position.
Make sure you don't double the third of the chord, and always double check there are no parallel 5ths or 8ves.