I need to replace a ceiling fan and add a round 1/2" deep pancake box. However, the clearance with the drywall is slightly off and leaves a gap in the ceiling when the ceiling fan is installed. Is it acceptable to notch the joist 1/8 to 3/16 of an inch? If not what are other techniques to solve this?
You can notch a joist up to 1/6 the depth of the joist. For example, a 2x10 can be notched 1.54166" deep (9 1/4" / 6). However, you cannot notch a joist within the middle 1/3 of the joists length. The notch can also only be 1/3 the depth of the joist wide. Again with the 2x10 example, that means the notch can only be 3.0833" wide (9 1/4" / 3).
Since ceiling fans tend to be near the middle of the room, it's likely that the intended notch location is within the middle third of the joist. Which means that notching the joist, could be dangerous.
You also cannot notch the joist if it's an engineered joist, without consulting the manufacturer or an engineer first.
For more information on notching and boring joists, please se.e this answer