、。
When he left the room, he bowed to me.
Literal
Room [object-を] exit [when-ときに], he [topic-は] me [to-に] bow [object-を] did.
お辞儀をする is the standard expression for bowing. Bowing on leaving a room is a natural Japanese social gesture, especially in formal or semi-formal settings. The を makes the bow the object of する.