In what situation the .NDF files are created?
You have a database with a datafile(PRIMARY) in a filegroup(PRIMARY) which stores metadata as well as user data. When you reach the maximum size of the datafile(depended on underlying Operating System) then you need to add an extra file which is know as secondary data file. According to the reference, datafile can grow up to 16TB, so for normal sized database this situation may no arise. So it's optional to have any secondary datafiles.  

However, these can be used to spread data across multiple disks by putting each file on a different disk drive.


  I'm curious to know under what conditions the .NDF files are generated ?


When you add extra datafiles on a database.


  If it is generated, how we can know which data base is behind it ?


It is added on A DATABASE. So you need to know database first in order to add the secondary data files. If you know that database then you can know the it's datafiles. 

More details and useful links are given here