From the Starcraft II Offical FAQ:
If I buy StarCraft II but don't buy any of the expansion sets, will I still be able to play online?
Yes. This will work similarly to Warcraft III and the original StarCraft, which maintained separate online gaming lobbies and ladders for expansion set players and players with the base Warcraft III or StarCraft.
In a nutshell, you'll always be able to play the game you have. The expansions will be standard Blizzard expansions, which you will have to buy if you want to play multiplayer with the "new units, abilities, and structures, along with new maps".
Edit: We've been speculating in the comments about whether the SCII:Expansion 2 will require SCII:Expansion 1. Our site isn't for speculation, so I thought I would provide the only data available, then drop it. (We could use similar hard data on how many players convert to the expansion and how many keep playing the vanilla game, but I will leave that to someone else. Maybe another question? Its possible Blizzard has released some relevant data about Starcraft I, Diablo II, or Warcraft III.)
Blizzard has only previously released one game with more than one expansion: World of Warcraft. Sadly, since WoW is an MMORPG where you need earlier content to reach later content, and Starcraft is an RTS which is broken into distinct game rounds, any comparison may be completely flawed, but its the only data we have:
- Burning Crusade, first expansion, only requires base game.
Wrath of the Lich King, which requires Burning Crusade
There must be a more official link for this, but it was not in the FAQ where I expected it.
Cataclysm (unreleased), which partially requires Wrath of the Lich King
See question "Will I need the expansion to be able to experience the Cataclysm changes?"