The markedness model (sociolinguistic theory) proposed by Carol Myers-Scotton is one account of the social indexical motivation for code-switching.
[1] The model holds that speakers use language choices to index rights and obligations (RO) sets, the abstract social codes in operation between participants in a given interaction.
In choosing a code the speaker evaluates the markedness of their potential choices, determined by the social forces at work in their community, and decides either to follow or reject the normative model.
[2] The markedness model operates within Myers-Scotton's matrix language-frame theory, a production-based explanation for code-switching that posits constraints on switches at the level of the mental lexicon (as opposed to that of the surface structure).
[2] Myers-Scotton gives the following example to illustrate the markedness model, involving a clerk and customer at a bank in Nairobi for whom the unmarked code choice is Swahili.
The customer begins speaking in the unmarked Swahili and later switches to Luo, their shared ethnic language, to index social solidarity with the clerk, trying to solicit extra help.
He contends that in switching codes speakers do not make reference to any pre-existing normative model but rather actively create and produce social meaning according to the particularities of the interaction.