Le is for indirect object, and Lo/La for direct object.
I recommend you to get familiar with that, you can make the mot of it, because it is useful for all languages including your own mother tongue.
Direct object [DO] → the thing the verb talks about.
Indirect object [IO] → The thing/person to whom it is directed.
Let's take your sentence. A sort of "original" form of that sentence is "Yo he dicho eso" = "I have said that thing".
The subject is clearly "yo".
Now, ask the verb
"WHAT have you said"? "eso" → "eso" is the DO.
"To what/to whom have you said that thing" → indirect object.
That's a practical rule that works almost always.
So you can write "I have told that to him".
What have tou told? "that" → "that" is the DO.
Who have tou told that to? "him" → "to him" is the IO.
So that's why you replace "that" by LO
and "to him" by LE
Le he dicho = I've told him
Lo he dicho = I've told that
And you can combine both, just be careful that "le lo " becomes "se lo",
Se lo he dicho = I've told that to him.