The correctly punctuated sentence is:
B. Lavender is a fragrant herb that is used to add flavor to many foods, such as tea and chocolate.
This sentence correctly uses a comma before the phrase "such as tea and chocolate," which provides examples of the foods to which lavender adds flavor.