Interestingly enough, there was exactly the same question in what the difference is in Japanese that I just answered today. The same principle is applied here.
는 is a general topic marker to express a general, neutral fact.
가 is a topic marker used when the topic was already introduced or the reference to the topic is clear.
As such, these are called "particles" and there are many of them. In your example,
네가 친구랑 갔니? (here I ignore the issue of honorific or familiar modes of speaking)
The implication is that you are being singled out. It's more like, "was it YOU who went with your friend" (in exclusion of other possible people).
너는 친구랑 갔니?
This simply asks whether it is true that you went with a friend.