This is one of the hardest points of English grammar to get.
There are many clues in the grammar and meaning of a statement that can help you determine whether to use the past simple or the present perfect, far too many to list here.
Get yourself a good grammar reference book. I recommend Practical English Usage by Michael Swan--it has seven