That is a great question. It depends on how your lease is written, but typically each person is jointly responsible for the apartment until the end of the least term. So, if one party fails to pay rent or if one party moves out, the remaining party can be held responsible for the full amount of the rent.
So, you need to take this step seriously and choose your roommates carefully. You might negotiate a plan up front as to how you will handle the situation in case of a breakup.