Interesting observation on strange behaviour using motors and IR transceiver
For me there are 3 possibilities:


This is a firmware bug There is nothing wrong with your hardware but there is a bug somewhere in your code. If you force your IR input to GND using a wire, solder or anything. Does the problem still occur?
There is something at the input pin for the IR. You can assess that by plugging an oscilloscope at the IR pin of your MCU. Your motor is probably perturbing the IR part. Maybe you are using a sensitive front end for your IR. The motor cables might be to close to the IR parts? 

Solution: Better insulation, better decoupling, physically separating the wires, etc...
There is nothing measurable at the IR input of your MCU but it's not a firmware bug. The problem might be the power supply. Do you properly decouple the power of your MCU? Where the motor power comes form? The same supply than the MCU? Is it regulated? It might be that the motor is drawing too much current or is creating too much noise into your power rails that the MCU get disturbed in some ways. Try to measure your power rails using an oscilloscope, if it is noisy or drooping, then this is your problem.

Solution: Use a proper voltage regulator, put decoupling caps at the pin of the MCU but also across the power supply of the motor, close to the motor.