PWM signal is affected when motor is connected
While your schematic does not depict the motor controller portion, if it represents a capacitive load (e.g. a FET gate) to the op amp this will often destabilize the op amp, particularly a unity buffer. Do some web searching for op amps driving capacitive loads, and you willl find plenty of app notes describing how to correct for this with capacitive feedback, etc.