"Which countries have you gone to?"
From 'A Dictionary of Basic Japanese Grammar': "The nominalizer こと turns not just a verb or adjective but an entire sentence into a noun phrase. ... In contrast to another nominalizer の, こと tends to indicate something the speaker does not feel close to/is not personally involved with."
I tried googling it and I think in this context it means something like "ever".
Grammatically adding 'koto' turns the verb into a noun, and the 'ga arimasu ka' asks if this noun exists, meaning "Has this ever happened?"
Your sentence ends with a verb in past tense followed by half a verb, it doesn't make sense.
You could say どの外国に行きましたか？ but that would mean "What foreign country did you go to" rather than "what foreign country/ies have you been to".
First, you don't say どの外国. どの国 means which country
Next, 行った ました is not grammatically correct. To say have gone to either 行きました or 行っています (used as a state) or 行ったことがあります