From how I understand it, it follows two simple rules:
1. The civilization who has the road inside their borders pay for it.
2. The civilization who built the road pays for it.
That's very simple if it's the same civilization for both, or if only the latter applies. The confusion is when there are different civilizations for the two, in which case rule #1 takes precedence. So when you conquer a city, you'll pay for the roads within that city's borders, even though someone else built those roads, but for the roads outside the borders the civilization who built them will pay, since only rule #2 applies for roads in neutral territory.
In even simpler terms: The civilization who has the road within their borders pay for it, and if none have it within their borders, the civilization who built it pays for it.
As far as I know, this is consistent, with the exception of possible bugs.