To begin with, the foundation referenced in verse 12 is the foundation of Christ (verses 10 and 11). Paul then explains there are two groups of people - those who build using gold, silver, and costly stones and those who build with wood, hay, and straw. Our works add to the foundation of Christ. Those who use gold, silver, and costly stones are the ones staying true to the Word of God. They live for the Lord, do what He wants them to do, love Him with every bit of their being. Their works will survive the fire and they will receive their reward.
The other group, though building on the foundation of Christ, have departed in some sort of way. Maybe their teaching is flawed or their time and gifts wasted. Their works will be destroyed by the fire. They themselves will be saved (because they are building on the foundation of Christ), but their works will not.
One day, all of our works will be put to the test. Will my work survive the fire or am I only adding to it? I pray I'm building with gold, silver, and costly stones, but I know I have some wood, hay, and straw in there. I look back and think about all the time I've wasted not doing what He wants me to do. I've watched tv, surfed the Internet, napped and so on. Don't get me wrong - there are times when we should rest. But the question then becomes am I resting because I'm tired or because I'm bored? Am I obeying the Lord or doing what I want?
I also wonder though if it's more than just doing the works? Verse 13 reads "...and the fire will test the quality of each man's work..." Does "quality" refer to our motives behind our actions? In Matthew Henry's Commentary, he writes "There is a day coming...that will show us our actions in the true light, without covering or disguise." If I do a good deed, but do it for selfish gain, then is it counted as gold or wood? I feel it would be counted as wood, since I was doing it for myself and not for the Lord. I didn't do it for the eternal good, but only for my temporary gain.
In the end, God is the final judge. This verse has me re-thinking some of the things I do though. My prayer is that whatever I do, I do for Him - out of love.