'
洋工' originally referred to work on foreign-commissioned (
洋) construction — the widely-cited origin is the 1917-21 rebuild of Peking Union Medical College Hospital (
协和医院), where Chinese laborers developed a reputation among American supervisors for dragging out tasks.
磨 ('to grind / wear down') +
洋工 came to mean 'to drag out foreigner-paid work', then generalized to any footdragging on the clock.