Asking a woman why she wants to work is a sexist remark, a tribunal has ruled.