I would say toward the end, unless you are trying to also darken the color or get molasses flavors. Then a longer boil will carmelize it. If is just to boost abv then you could secondary. They could each give different outcomes but they would be very minor differences.
If you want some of the complexity of a Maillard reaction add it early in the boil, otherwise, adding it at flameout is fine. The time it takes to cool the wort from 212 to below 160F is sufficient to pastuerize the added sugar...if that's even necessary. If it's liquid it's easier than if it's rock.