In the early stages of the game, you need to make sure you aren't just continually hitting the creep, as this is 'pushing' and isn't really meant for early game. Just make sure to get the finishing blow ("last-hitting") in order to gain a gold bonus.
A good laning enemy will be trying to harass you as much as possible, so you will want to make sure you head in, last-hit a creep, and then get out again. This is that much more important for melee heroes laning against a ranged hero.
As for attacking heroes, I assume you mean harassing, getting a few hits in and then retreating. It is safest to do this when the enemy creeps are near your own tower, and the enemy hero is there as well. This is easiest to do on the Radiant bottom lane (as Radiant) and the Dire top lane (as Dire). These are the 'safe lanes' of the respective factions.
There is no most efficient way to do right-clicking itself, it is all down to habit and personal preference. Some people like to last-hit and then run a few steps towards their enemy laning partner, as a threat in order to get them to back off from the creeps themselves. Most people just run in, get a last-hit, then run out.