Jens Stoltenberg was commenting hours after Scottish First Minister and SNP leader Nicola Sturgeon announced her intention to hold a second independence referendum.
He said: "If it happens (Scotland becomes independent), then UK will continue as a member of NATO but a new, independent state has to apply for membership and then it is up to 28 allies to decide whether we will have a new member.
"By leaving the UK, it will also leave NATO.
"But of course it's absolutely possible to apply for membership and then the allies would then decide whether a new independent entity or state will become a part of NATO."
Although an independent Scotland would probably satisfy most NATO criteria, the accession process typically takes many years and it would have to be ratified by the other 28 members.
The SNP was previously opposed to NATO but reversed that position in 2014. Ms Sturgeon said she would seek to join NATO were Scotland to achieve independence.
One issue would almost certainly be the SNP's opposition to the UK's nuclear deterrent which is currently based at Faslane on the west coast of Scotland.
It is unlikely the UK would allow its nuclear submarines to remain in an independent Scotland, which involves an expensive relocation process.
And NATO might look dimly on Scotland's opposition to nuclear weapons considering NATO is fundamentally a nuclear alliance.
Scotland would be entitled to its fair share of the UK's current armed forces and would need to build its own defence capabilities.
Chancellor Philip Hammond, who was defence secretary during the 2014 referendum, made fun of that suggesting that Scotland would get five Chinook helicopters, 10 fighter jets, one sixth of an aircraft carrier and less than one Red Arrow.
Independence could also affect the Scottish economy.
The country is a hub for defence manufacturers with major companies such as BAE Systems and Thales having bases north of the border.
Most Royal Naval warships are built on the Clyde outside Glasgow, but the Westminster government would transfer those facilities south, probably to Portsmouth, for national security reasons.