Apply a Material just to the part of an object that was edited by a boolean modifier
This is how it works by default - materials transfer from one object to another with boolean operations. You just need to have material slots for all the materials used on both objects.
So if you just add a material slot and set it to the same material as the object that you use for boolean operation has it will transfer to that area.