The effect of surface passivation and crystallite size on the photoluminescence of porous silicon is reported. Oxygen-free porous silicon samples with medium to ultra high porosities have been prepared by using electrochemical etching followed by photoassisted stain etching. As long as the samples were hydrogen-passivated the PL could be tuned from the red (750nm) to the blue (400nm) by increasing the porosity. We show that when surface oxidation occurred, the photoluminescence was red-shifted. For sizes smaller than 2.8nm, the red shift can be as large as 1eV but for larger sizes no shift has been observed. Comparing the experimental results with theoretical calculations, we suggest that the decrease in PL energy upon exposure to oxygen is related to recombination involving an electron or an exciton trapped in Si=O double bonds. This result clarifies the recombination mechanisms in porous silicon.