The Bafang motor is noisy at low speeds and slogging up hills but should get quiet as it approaches full speed at around 15 mph.
If yours is noisy all the time, it could be the alignment of the inner core in the shell or noisy gears in the rack. When the core is withdrawn from the hub shell, it's inside spindle on the gears side has shims on it to give the right alignment. If you are confident enough to strip it, you could try reducing or increasing the number of shims to see if that corrects it's noise, but don't increase the shims enough to make the windings collide with the hub shell side plate.
There's not much you can do about the hub shell gear rack and gears unless they show signs of damage when replacement does the trick. The rack is held in with screws.