Onto can also be used in its open form, where it is on to. It is normally used with the following sense of on in the case of physical activity of the kind you describe:
1 a —used as a function word to indicate position in contact with and supported by the top surface of
// the book is lying on the table
When using onto in this sense, you are denoting a sense of motion, where something is moved to be in contact with the top surface of something.
But when simply using just on with a verb that describes physical action, it generally means against, in the second sense of on:
1 b —used as a function word to indicate position in or in contact with an outer surface
// the fly landed on the ceiling
// I have a cut on my finger
// paint on the wall
In these examples, the outer surface of something can be top, bottom, or side. But context will determine the direction.
Therefore, consider the difference between the following two sentences:
I leaned on the door.
This is the equivalent of saying that you leaned against the door. Your entire body, from feet to head, could be connected with the vertical surface of the door.
I jumped onto the door.
This is the equivalent of saying that you jumped across or down from somewhere else, and ended up with your feet, or other parts of your body, in contact with the top of the door.
Or, possibly, the door is not attached to a door frame, but is lying flat on the floor. In that case, you jumped on top of its horizontal surface—something that, because of gravity, is not possible when it's in an upright position.
If somebody runs and jumps, causing their feet to contact the vertical surface of an attached door, we would still not say that they jumped onto the door, we would say that they jumped into the door.)
Let's go back to your original sentences, and looking at them in reverse order.
I rested my head on the tree.
This would normally indicate that you placed your head against the tree trunk, or against the side of the tree.
I rested my head onto the tree.
This sounds strange and is not something that would normally be used. The reason for this is that onto still has the equivalent interpretation of I jumped onto the door.
In other words, what this suggests is one of two things:
You climbed to the top of the tree and then rested your head against its upper branches.
You jumped from one tree to another, or were dropped from above, and ended up on top of the tree, where you rested your head against its upper branches.
We would likely not interpret it this way (because it wouldn't make sense) but we would still feel there was something off about the sentence.
Onto is not normally used with rested or leaned. And it's not used because of this strange association.
In describing something resting or leaning, we would either say on or against, not onto.