JimB said:
From the point of view of protecting the transistor from the back-EMF from the relay coil, solution B is probably as good as solution A.
But, if there are other circuits nearby which are sensitive to magnetic fields, use solution A.
The problem with B is that you have a large loop of wire, from the relay to the diode, from the diode to the supply, from the supply to the relay. When you de-energise the relay, a large current pulse will flow in this loop and create a varying magnetic field which will induce voltage spikes into other nearby wiring.
If you find the cost of relays with diodes too expensive, would it not be possible for you to modify a standard relay and solder a diode across the coil?
JimB
De-energizing the relay does not cause a large current spike. The current that was flowing through the relay when it was energized simply looks for another path, because it can't stop flowing instantaneously.
Actually, in B the current in the wire to the relay will decay relatively slowly when the transistor is turned off, while in A the di/dt in that wire will be much higher, causing a voltage spike v=L(wire)*di/dt, which is what Styx was alluding to. The EMI from A will be worse than that from B. When the transistor turns on, di/dt will be about the same in both cases.