The weak pull-up resistors of Port B are off by default. Also, they are active only if the pin is configured as an input pin. So, they aren't the cause of your problem.
I'm not good with electronics, but as far as I know, a motor is an inductive load and it may cause sudden voltage changes in the circuits when it starts and stops. This can cause a device reset. Make sure you have some capacitance in your circuit, like 100 uF. If it doesn't help, try to isolate PIC from the motor, by using optocouplers and separate sources of power.
Also, search the term "flywheel diode", and make sure you use it. I am not able to explain its logic because of my poor electronics skills, but you can find lots of information about it on the internet.