In a general sense, you want to do a roughly equal amount of good or bad things throughout the game.
In a specific sense for the achievements, you want to just save shortly before hitting levels 7, 14, 20 and 30 and do bad or good things to change your karma before you level-up.
If you're good, go on a bloody rampage in a city right before you level-up... stop killing when you hit neutral. If you're bad, donate to a church or do a positive karma quest before level-up... etc.