If I play a tile which completes an empty city, must I place a knight in it? Or am I allowed to place a farmer instead?

As long as the farm is vacant you can place a farmer in it. No-one will score for the city. But you can only play one meeple, so you can't place both a knight and a farmer on the same turn.