The fuse rating is to match the load you are pulling, i.e. if you are installing two 27w lamps, the current draw (load) is these two combined (54w).
Power(P) in watts is calculated as voltage(V) times current(I) in amps; [P=VxI], so to work out the current we divide the power by the voltage.
So this gives 54w÷12v = 4½amps (the car's voltage will change depending on revs and battery condition etc. , i.e. if you calculate using 13.5v the current works out at 4amps, 0.5 amps less, 11.5v is 4.7amps)
Fuses come in different current ratings so in our case we'd be looking at fuses in the range between 4, 5, 7½, or 10. I would use either the 7½ or 10 amp depending on what I had handy, doesn't matter that it's a bit more, however 4 is definitely too small, and 5 is cutting it fine if your voltage drops below 12v (say at idle or if the motor is off).
BTW the 40amps of the relay is the maximum the contacts of the relay is designed to take, so whilst you can use it on your twin 27w fog lights, this same relay with a 40amp fuse can handle twin spotties of up to 240w each (480w total) at 12v. You would need to make sure all other components in the system were also suitably upgraded especially the wiring and connectors/terminals.