Source:Dota2.gamepedia.com
Last hitting
Last-hitting is a technique where you (or a creep under your control) gets the 'last hit' on a neutral creep, enemy lane creep, or enemy Hero. This is the only way to get gold from creeps apart from Hand of Midas, Devour, Death Pact, or Demonic Conversion, and gives much more gold than otherwise when done to towers or Heroes. 
Creeps are your 'safest' bet on using last hits to gain a good 
chunk of gold. This is the primary source of gold in Dota 2. It is 
always desirable to get a last hit on a creep, although when laning with
 a partner it is often polite to give them some last hits, and is quite 
important when they are a carry. Supports should focus on harassing enemy Heroes and denying your own creeps. 
Auto-attacking refers to the usually less desirable technique of 
simply letting your Hero attack at will. Since this rarely results in 
getting the last hit, this has very few benefits. In the late game, 
however, Heroes often do enough damage to simply auto-attack and still 
gain all the last-hits. Auto-attacking can be useful in any case if you 
wish to push a lane forwards, since it kills enemy creeps faster. This 
is especially useful for killing towers. In the early game, however, 
pushing towards an enemy tower is considered dangerous, as it leaves you
 far from your own towers and makes it much easier for enemies to gank you.
Heroes
 also give gold when you kill them. Everyone who did damage to an enemy 
Hero within 15 seconds of their death gets an assist. If you were the 
Hero who delivered the last hit you will get the kill and the bonus gold
 for it. If your tower or one of your team's creeps gets the last hit on
 an enemy Hero, the gold is split between all Heroes who got an assist. 
If only one Hero hit the enemy before your tower or creep killed them, 
that Hero gets the credit (and the gold) for the kill. If no allied 
Heroes assisted in the kill, the gold is split evenly among all five 
Heroes on your team.
Towers
 give a global bonus of gold when destroyed, but they also give a hefty 
amount of bonus gold to any hero who manages to get the last hit on one.