The phrase brand spanking new means to be entirely new or recently created, and was first recorded in 1860. It evolved from the compound word brand-new and the phrase spick-and-span. Also, spanking, while the main definition is to hit someone on the butt, can also mean to move quickly. So one might say that a brand spanking new object was created quickly or appeared very fast. In truth, no one knows quite how it was coined or what it originally referred to.
This idiom is not officially recognized in most dictionaries, and as such does not have an official spelling. Most instances are hyphenated, since the phrase is used as a compound adjective. Though since hyphens in general are on the decline, an argument could be made for not using them. There are some publications which prefer hyphenating brand-spanking and not new, so that it is new that is being modified.
In the end, it is personal preference since this idiom is informal.
What better way to do it than whilst wearing a brand spanking new pair of kickers. [Mirror]
When our castles start to age, we blow them to kingdom come, record the explosion, and showcase that video on a giant screen at our brand-spanking new casino. [Las Vegas Review-Journal]
If you’re interested in a wine-centric happy hour in a brand-spanking-new space, Klyde Cafe and Wine Bar is your destination. [Haute Living]
“15-20 percent of the folks that we see are brand spanking new and never been to our food pantry before,” said Russell. [WSIL TV]