Formal:
* Mais parfois: This is the most direct and common translation.
* Toutefois, il arrive parfois que: This is more formal and emphasizes the occasional nature of the event.
Informal:
* Mais des fois: This is a more casual way to say "but sometimes."
* Parfois, mais: This puts the emphasis on the "sometimes" part of the phrase.
Examples:
* J'aime le fromage, mais parfois je préfère le chocolat. (I like cheese, but sometimes I prefer chocolate.)
* Il est généralement calme, mais parfois il devient très agité. (He is usually calm, but sometimes he gets very agitated.)
* Je suis fatigué, mais des fois j'ai envie de sortir. (I am tired, but sometimes I feel like going out.)
You can also use phrases like "de temps en temps" (from time to time) or "à l'occasion" (on occasion) instead of "parfois" for a more nuanced meaning.
Ultimately, the best translation will depend on the specific context and your desired level of formality.