on the top of means on the external top of an object and they are usually in touch with each other.
e.g. You'd better put the book on the top of the desk.
at the top of has two aspect meaning, one is at the top of a internal part of an object.
e.g. The fifth floor is at the top of the building.(The building totally has five floors.)
Contrast: He stands on the top of the building.(I mean he stand outside the building, the platform of the sky the buiding proped up.)
And the other meaning related to abstract aspect.
e.g. He shouted at the top of his voice. He is at the top of the class.