Can you hit your opponent's back in fencing?
Yes, the back is valid target in all three weapons. In foil the target is the torso, front and back, from the collar down to a horizontal line across the back joining the tops of the hip bones, plus the lower part of the mask bib; arms, legs and head are off target. In sabre the target is everything above a horizontal line between the tops of the hip bones, carried all the way around the trunk, so the back, arms and head all count. In épée the whole body is target, including clothing and equipment, so a hit anywhere on the back scores.
What is not allowed is turning your own back to avoid being hit. Turning your back on your opponent during the bout is a first group offense in every weapon: a yellow card the first time, a red card for a repeat in the same bout, and any touch you score while doing it is annulled. Your opponent's hit on your back is judged normally. When one fencer runs completely past the other, the referee halts. A hit made as they pass counts, and the fencer who was passed may still score with an immediate hit even while turning around, but a hit made by the runner after passing is annulled.
Most deliberate back hits are flicks: a whipping action that bends the blade so the tip lands over the shoulder on the shoulder blade. They show up most in foil and épée. In épée the common moments are after a late, deep parry when the opponent closes or flèches, or over the shoulder of an opponent who leans far forward on the lunge. The épée tip needs a firm landing to register, so a flick takes a strong, practiced wrist, and getting close enough to land one also puts you in range to be hit almost anywhere, where a double still counts for both.
If you want to learn it, ask your coach rather than teaching yourself. Flicks hit hard, depend on precise distance and are built on top of solid parries and point control, so most coaches add them once the basics are reliable. If an opponent keeps flicking your back, the fix is distance: stay out of the short range flicks need, stand tall rather than leaning forward, and make them come to you.