In Morocco, covering the head with a scarf is not mandatory. You will see women with head scarves and women without. Niqabs are scarce and burqas are prohibited by the State. That said, traveling with a scarf is a good idea.
Do female tourists have to wear hijab?
As mentioned above, tourists should respect hijab laws too. But most of the time, they don't have to wear it as strictly as Iranian do. But remember, in holy places such as Imam Reza Holy Shrine, Fatima Masoumeh Shrine, or Jamkaran Mosque you have to wear a chador; either a black one or a colorful one.