Most of his philanthropic efforts have been conducted through the Musk Foundation, which reportedly holds around $16 billion in assets.
The Trump account program was designed to give every American under 18 a stake in the stock market and to help build wealth from an early age.
He set out the pledge in a brief post on X, the social media platform he owns.
In a separate post, Musk said the company shares will be transferred next month, with his own to follow later.
SpaceX shares closed at $127.44 on Wednesday, valuing the pledge at nearly $18 billion.
The company said the initiative, worth around $54 billion at current prices, would give it more flexibility and scale to make donations for the benefit of humanity.
SpaceX did not immediately respond to a request for comment on whether Musk's own donations would also be linked to Trump accounts.
As of June, Musk held about 6.42 billion shares in the company.
Musk and the rival artificial intelligence company Anthropic have recently set out sharply different approaches to sharing the gains of the AI boom.
Anthropic, which went public earlier this month, said it would commit 5% of its shares to a new fund for the"public good".