Power relay makes ESP 07 to reboot(trying to control an electrical motor)
If you are using a relay I think it's fair to assume that input and output are isolated, therefor there should't be any backfeed from the relay. Unfortunatly there is still the possibility of capacitive or inductive coupling.
The PSU has some internal filters, that will inhibit the transients from reaching the primary side. That's for my assumed explenation.

Regarding the solution, there are 5V Optocoupled relay modules widely availible, if you power such a module with your 5V from the Motor power supply and use the integrated octocoupler, your problems should be gone. Depending on the input characteristics of the optocoupler it might be neccessary to insert a darlington stage, since I assume the drive capability of the ESP07 is limited and propably around 3V (which should actually suffice to drive the optocoupler).