The back office exists for three reasons: clearance, settlements and accounting. These three function interact directly with external agencies like the custodian (actual holder of the security), the clearing firm (third party) and a commercial bank. The back office maintains external relationships and control functions and is where the trade ends.
The middle office, as the name implies, is a hybrid function between the front and back office. The middle office handles validations (of stock orders), bookings (orders) and confirmations. Technically, these are all back office operations, however, they often require the help of front office staff to resolve.
The front office is responsible for trade capture and execution. This is where the trade originates and the client relationship is maintained. The front office makes/takes orders and executions. Traders and sales staff are considered front office staff.