When do you know what type of Spanish to speak in different countries?
Don't worry about it. It's like worrying about whether you're learning British, American, or Australian English.
I learned Latin American Spanish and I have had conversations with folks from Peru, México, Argentina, Spain, Guatemala, Colombia... other than slang, the odd different word/meaning here and there, it's all pretty much the same. If you speak standard Latin American Spanish you will not have any trouble at all being understood no matter who you talk to.