In a native way: 小时候,我每天上学要走一里路。
当我是小男孩时,我每天步行一里路上学。
In Chinese, people use more verbs than nouns. Like here "to school", in Chinese, it changed to a verb"上学"or two verbs come together “去 上学”. It's Ok to use the noun “学校”, but remember to add a verb in front of it: "去 学校"
“了” means "have walked...", so it's better not use it here.
"当我是男孩子的时候",don't forget to put"是"here.
“步行”and“走” are both right, “步行” is more used in written and formal language.But you should put "一里" after verbs. So "步行一里到学校“