The two words 'while' and 'whilst' mean the same thing. They could be considered alternate pronunciations of the same word, similar to among/amongst or further/farther. 'While' came first, and then 'whilst' was derived from it.
But they are not used with the same frequency and they give different 'feels'. 'While' is much more common (from Google nGrams)
'Whilst' sounds archaic, affected, or hyperacademic (which means no one in academia uses it).
To Americans, 'whilst' sounds British, but at least in print, there is very little difference in the frequencies of the two words between AmE and BrE (via Google nGrams)
In the end, it is correct grammar to use them interchangeably, but it is bad style...uh sorry, not the current fashion to use 'whilst'. No one (at least not in formal writing, like for newspapers or academic writing) uses 'whilst' anymore. It may be common and accepted in certain varieties of English (say Indian English) but is very jarring in standard English.
However, in the 18th century the two were on more equal terms. The classic study of text analysis by Mosteller and Wallace to help discover the authorship of the Federalist papers was based primarily on the use of differentiating pairs like this.