Many pathogenic and commensal bacteria species are split into distinct strains that are stable through time. This strain structure is characterized by linkage disequilibrium (LD) in the distribution of alleles, meaning that some alleles are found together in genotypes more (or less) often that expected by chance. This structure leads to significant correlations between the distribution of phenotypic traits in the population. One such example is the correlation between invasiveness and antigenic loci in Streptococcus pneumoniae, which has allowed vaccination to reduce overall invasiveness by targeting certain serotypes. A stable strain structure, and thus a stable linkage disequilibrium between certain loci, first requires a stable diversity of alleles which can be maintained by balancing selection for example through negative frequency-dependent selection (NFDS). For commensals such as S. pneumoniae which are often found to co-colonise hosts, metabolic competition is one mechanism which can lead to NFDS. Yet NFDS alone is not sufficient to create strain structure and maintain LD. Indeed, the determinant factor generating LD is epistasis between loci, which denotes that the fitness effect of an allele is conditional on the other alleles found in the same genotype. In this work we use mathematical modelling to study how the combining of NFDS across loci in different biological scenarios will lead or not to epistasis and, in turn, to LD and stable strain structure. With loci under NFDS through metabolic competition, we find a range of possible scenarios, from actively maintained to actively destroyed LD. Interestingly, we show that these behaviours can be understood in terms of emerging frequency-dependent selection at the genotype (i.e. strain) level which can be negative – equalising genotype frequencies and abolishing strain structure -but also positive – maintaining and strengthening existing structure. The presence of positive frequency dependent selection on strains means that adaptation is contingent on past evolutionary history. This has implications for predicting outcomes of publish health interventions that perturb strain frequencies, such a vaccination campaigns. We also generalise these findings by examining the effects on strain structure of other mechanisms which impose NFDS such as immunity, or host population structure.