while, incidentally, at the same time
Expresses doing something incidentally while doing another action, meaning 'while at it' or 'by the way'.
ついでに is used when you take advantage of an opportunity to do something else at the same time or place. It implies the main action is the primary reason, and the secondary action is done because it's convenient. For example, if you go to the bank, you might also buy stamps nearby. The pattern is often translated as 'while I'm at it' or 'incidentally'.
You attach ついでに to the past tense or dictionary form of a verb, or to a noun with の. So you say 買い物のついでに, not 買い物ついでに. Also, the main action is usually stated before ついでに, and the secondary action comes after. The sentence structure is: [main action] ついでに [secondary action]. Note that the main action is the one you're already doing, and the secondary action is the bonus.
This pattern is neutral in register and can be used in both spoken and written Japanese, but it's more common in everyday conversation. It's not overly formal or casual, so you can use it in most situations.