Named the Indo-Afghanistan Friendship Series, the one-off Test will be held within three weeks of this year's Indian Premier League (IPL) final and ahead of India's tour of England.
Afghanistan have earned their Test status in June past year.
The Board of Control for Cricket in India (BCCI) said it welcomed the opportunity to host its "friends" for their first Test since Afghanistan became a full member of the International Cricket Council (ICC) previous year.
Both country's cricket boards announced the news on their respective twitter accounts. "People in Afghanistan have been waiting to see the team play a Test and the fact that it will happen against India in India, is a dream situation".
"India and Afghanistan's relationship goes back to centuries, and cricket has only added to it".
"It will be (a) tough challenge for Afghanistan against a mighty Indian team but a pleasant one and one that we will learn a lot from", Stanikzai said. The match will mark the debut of Afghanistan in Test cricket. The Test match against Afghanistan would hence be coming before that.
Last year, the International Cricket Council had announced Ireland and Afghanistan as the two newest cricketing nations to be awarded Test status.