How often you harass is based largely on the champion you're playing as well as the positioning of your opponent. Unlike in the bottom lane where you can safely harass from behind your own minions, oftentimes a top champion has to be in your wave to harass you, or you have to be in theirs to harass them. At early levels, having an entire minion wave aggro onto you can deal much more damage than a champion can, so use that to your advantage. If it's a melee top laner, try and bait them into wasting skillshots on your minions, and when you can see that they're either low on mana or have just used up their abilities to farm go in, get a few hits, and then quickly back away so you don't have to walk back through a bunch of angry minions. Learn how to deal with champions who have serious early game advantages and lane bullies, because in cases like a Darius or a Renekton your best option is to play passively and wait for them to make a mistake.
If you're a melee and your opponent is ranged, there is no real way to avoid taking poke. They can stand behind their wave and hit you when you go to CS their front minions. As a result they farm safer and are more liable, like lane bully tops, to push the lane. This makes a favorable position for you because a ranged character will most likely have lower defenses and health, making them much more susceptible to ganks. Ranged top laners will usually have some form of CC, but no real escapes outside of Vayne or Teemo, and they won't have enough CC to run from both you and your jungler. Again, play passively, farm what you can, and take advantage of their mistakes. Consider building with a defensive focus, and taking a Doran's Shield, even if it isn't the best choice for your character, can mitigate the damage they're doing since most of it will be AA based.
Roam either when you've pushed your lane up to the enemy turret, or when you have completely taken it. Remember that if you free push to turret, you can pretty safely head to midlane for a quick gank in the time it will take them to push back to yours. Use that to your advantage to come in behind them and trap them between you and your oncoming wave. It's better if the jungler or the midlaner joins in when you head back to top lane.
The last one depends more on your champion. Someone like Darius or Wukong does a lot better harassing the opponent, and has ways to get CS while doing so (i.e. Darius' spin, Wukong's Nimbus Strike). If you're playing an aggressive champion, your best bet is to rush in, do some /quick/ damage, and then rush back. A good example would be Renekton, who's standard combo goes something like spin > AA > W > AA > Q > spin back. That's four hits, one of which is a brief stun that sets you up for the second AA, and then the Q heals you for a small amount just before you dash back, dealing damage the whole way. If you're playing a more passive top, you focus on farming. Passive top laners tend to have much stronger late games, like a Jax. Early on, Jax can have some difficulty, but once you build your first few items you hit a power spike and can then start going in much more reliably, and your skills have scaled up to the point where they're doing a good amount more damage.
The long and short of it is that the toplane is very much a tug of war. It's easy to get countered, easy to counter, and relies heavily on your own knowledge of positioning, of enemy champions, and map awareness. Your best bet isn't to learn any one way to handle top lane, but to learn how the champions you enjoy most handle the top lane in their own ways.