The coupled effect of wall heat loss and viscosity friction on flame propagation and deflagration to detonation transition (DDT) in micro-scale channel is investigated by high-resolution numerical simulations. The results show that when the heat loss at walls is considered, the oscillating flame presents a reciprocating motion of the flame front. The channel width and Boit number are varied to understand the effect of heat loss on the oscillating flame and DDT. It is found that the oscillating propagation is determined by the competition between wall heat loss and viscous friction. The flame retreat is led by the adverse pressure gradient caused by thermal contraction, while it is inhibited by the viscous effects of wall friction and flame boundary layer. The adverse pressure gradient formed in front of a flame, caused by the heat loss and thermal contraction, is the main reason for the flame retreat. Furthermore, the oscillating flame can develop to a detonation due to the pressure rise by thermal expansion and wall friction. The transition to detonation depends non-monotonically on the channel width.