The effects of AWG and EDFA on BER are studied in this paper. An analytical model of BER performance is developed as a function of the output port location in the AWG and the distance of the receiver from the AWG. Not only does the proposed model capture the power loss caused by AWG, but it also accounts for several transmission impairments, including the beat noise due to inter-channel crosstalk in the AWG, the amplified spontaneous emission (ASE) noise related to EDFA, and the thermal noise related to the receiver. Based on this model, we propose both short-term and long-term distance-aware wavelength allocation schemes, which balance the BER among the optical network units (ONUs) at different distance. Simulation results show that average BER improves and the relative standard deviation decreases.