This web site has a good summary of standard practice:
Generally, you want to stay out of the middle third of the span (measured horizontally) because that has the greatest bending stress. You also want to be in the middle third of the joist (measured vertically) because that has the lowest bending stress. There are other standards for notches, this web site is pretty good. For a DEFINITIVE answer, check your local building code, or discuss with your local building inspector.