Since we're talking about basicity, we're looking at the following reactions:
R-OH + H
+ R-OH
2+R-NH
2 + H
+ R-NH
3+So, one way to consider the problem is to consider which product is more stable, R-OH
2+ or R-NH
3+. In other words, which atom is more stable with a positive charge: oxygen or nitrogen.