Ordinarily the first term will be one which has already been introduced into your discourse, and the second will provide a more specific identification.
The boy Tommy identifies Tommy as the particular boy you are talking about: this boy rather than that boy.
Mrs. Kowalski identified the boy Tommy as the one who had stolen her handbag.
The boy Tommy has been located, but Jimmy is still missing.
Tommy the boy identifies the boy as the particular Tommy you are talking about: Tommy the boy rather than Tommy the girl, or young Tommy rather than grown-up Tommy.
Tommy the boy is rather stupid, but Tommy the girl is a math prodigy.
Tommy the boy was always in trouble; but now he is Chief Justice of the Supreme Court.
Sometimes the second term is bracketed in commas or parentheses; this marks the identification as 'supplemental', additional information of secondary importance:
The boy, Tommy, has brown hair and is about 4'10" tall.
Tommy, the boy, has been located, but his father Jimmy is still missing.