Yes, it is safe to put a candle by a window. The flame will be drawn up by the draft from the window, and the heat from the flame will help to keep the window clear of condensation. However, you should be sure to keep the candle away from any curtains or other flammable materials, and you should never leave a lit candle unattended.