Both of them mean "wall", then what's the difference?
2 Answers
壁{かべ} is a regular wall. 塀{へい} may be a wall but not necessarily. A 塀 enclose a perimeter (like a house, a building, ...) and it define a frontier between the interior and the exterior. A wall does not define an interior and an exterior (just two sides: in front of the wall and behind the wall). Therefore, sometimes 塀 is translated as a fence.
You can have a look at google images to get a more precise idea.
On a first glance, they both seem to mean the same thing. 壁 is used more frequently in Japanese, in the essence of common words it participates in, like 完璧, 障壁 e.t.c. 塀 on the other hand is more commonly used alone, with the meaning "fence, wall". Of course there are words that use the Kanji, like 石塀, ブロック塀 e.t.c. but they are not as common.
If you want to know why the first wall Kanji differs from the second both in usage and frequency, you'll have to resort to Kanji etymology.
壁 comes from the element 土 which you may be familiar as "soil, clay" and a 辟 is a phonetic element. That means, it is used to convey the reading of the Kanji. There have been some sources (e.g.Henshall) tying the usage of 辟 us a phonosemantic element, meaning it is also used not only because it gives the Kanji reading, but it also builds around its meaning, more specifically "law, restriction", thus "clay restricting something->wall".
塀 is tied many times with 垣 that has again the same meaning (some consider the former the variant of the latter). 塀 is mostly considered a Japan-created variant. 土 is again "soil, clay" and 屏 among others means "barrier, shield" in Chinese.
So building up to @永劫回帰 answer, 塀 carries not only the meaning of a regular wall, like clay restricting something (壁)but also "shielding, protecting, defending", thus most frequently used to define an exterior walling, something that doesn't passively restrict entry but "shields" or "defends", like a fence.