You're talking about "kiribi," the striking done to make sparks. The sparks are considered "pure and untainted" for being just borne and therefore able to drive away back luck and evil.
You see it very often in samurai drama, as an expression of good luck to the person leaving the home to head to work or to do something important. However, the practice still lives among artists and craftsman who preserve traditional Japanese arts.
http://www.kaiun-navi.jp/navi/contents/hiuchi_use1.html