Basically you have to memorize the correct usage of each verb. It's not always possible to logically tell which verb takes which particle. Many English transitive verbs are translated using intransitive verbs in Japanese, and vice versa. See this answer, too.
But roughly speaking, verbs that describe actions which directly and heavily affect the object tend to take を. Some "mild" verbs may take に. That's the basic difference between transitive and intransitive verbs, after all.
- 彼を殴る, 彼を蹴る (to kick him), 彼を縛る (to bind him), 彼を殺害する (to kill him), ...
- 彼に頼む (to ask him (a favor)), 彼に感謝する (to thank him), 彼に挨拶する (to greet him), ...
For compound verbs, the second verb usually determines the particle it takes.
- 彼を殴る 彼に殴りかかる 彼と殴り合う
- 彼に聞く 彼から聞き出す