In the presence of peers, people typically act in a way that they think will be acceptable to the others. This typically means not following the standard, expected rules, but rather what will receive the most acknowledgment or praise from peers. The same works for adults!
For the child engaging in these behaviors, consider spending some time on the side teaching appropriate words and actions. Then put into practice additional praise or reinforcement that will encourage these to happen more often.
Example: A child that swears in the middle of class, to get a reaction out of peers. Talk with the child on the side, outside of the classroom teaching time, and discuss appropriate ways to interact in the classroom. You can raise your hand, you can write a note and pass it to the teacher, you can doodle on the side of your notes (if you are still paying attention), etc. Determine what is reinforcing for that child, and reinforce heavily. If a sticker chart with access to a computer break works, then you want to deliver stickers before the behavior typically happens. You will want to gather some baseline data…. how much time is in between the swearing (interresponse time)? when does the language typically occur (only during certain activities? in the presence of certain people? particular time of day?, etc.). If you determine that the language occurs throughout the day, and about every 3 minutes, then you want to reinforce the child with a stick about every 90 seconds! When first implementing the token economy, you will provide the child access to the computer for about 3 minutes for every sticker. Repeat for about a week, then transition to 2 stickers then 3 minutes of computer. Continue until the child is either not engaging in swearing anymore, or is attending to the majority of a lesson (about 20-30 minutes) before needing a break! Over time the sticker chart will not be needed.
Also consider putting into place a classroom contingency that if all follow the rules (including appropriate language), they can earn a few minutes of a preferred activity (i.e. recess, free time, break time with a peer, class game, snack, etc.). This will also encourage peers to keep other classmates engaging in appropriate behavior, so they can all earn something!