The phrase "treasure in heaven" comes from a conversation between Jesus and a rather wealthy young man who had approached Him with a question about eternal life.
Jesus said to him, “If you would be perfect, go, sell what you possess and give to the poor, and you will have treasure in heaven; and come, follow me.” Matthew 19:21 (ESV) His reaction to our Lord's challenge to sell all he had proved that the young man was more interested in earthly treasure than he was storing up treasure in heaven.*
There are other passages in the Bible that speak of storing up treasure which, like the passage in Matthew, are connected to the use earthly wealth. Check out this passage from Paul's letter to Timothy:
As for the rich in this present age...they are to do good, to be rich in good works, to be generous and ready to share, thus storing up treasure for themselves as a good foundation for the future, so that they may take hold of that which is truly life. 1 Timothy 6:17-19 (ESV)
In his letter to the church in Philippi, the phrase "treasure in heaven" wasn't used, but I think you'll see that Paul had that same concept in mind when he wrote:
...even when I was in Thessalonica, you sent me aid again and again when I was in need. Not that I am looking for a gift, but I am looking for what may be credited to your account. Philippians 4:16-17 (NIV)
The "account" that Paul wanted to see "credited" existed is in heaven. In other words, Paul was saying he was looking to increase the Philippian's treasure in heaven.
Although there are other passages which do a good deal more than suggest that our financial generosity will be amply rewarded by the Lord, (see Proverbs 19:17), I don't believe giving one's money is the only means of storing up treasures in heaven. In fact, any good works on our part are more assuredly a way we can store up treasures. And God has made that kind of thing abundantly possible by actually providing good works for us to do in advance. (See Ephesians 2:10)
The Parable of the Talents was told by Jesus to underscore the fact that God has not only given us stewardship of all kinds of gifts, abilities, and resources to invest but also to make clear that He will ask us one day to account for how faithfully we have used those things on His behalf. (See Matthew 25:14-30) This is unquestionably a key to storing up treasure in heaven.
*Check out my teaching on the rich young ruler from Matthew 19