Yes they are both correct.
"By" can be used to indicate the means of transport......by car, by bus, by train, By FOOT
"On foot" means "on one's feet, walking or running".
They basically mean the same thing. "On foot" is more common.
However, there is a small difference.
If you hired someone to take you home from work every day, and they walked carrying you on their shoulders, then, you would be going home BY foot, but you would NOT be going home ON foot.