The former One Direction star, 26, replaces Shia LaBeouf who departs the production due to scheduling conflicts.
It will be his second big-screen acting role, after appearing in 2017’s Dunkirk alongside stars including Tom Hardy and Sir Mark Rylance.
Directed and produced by Olivia Wilde, Don’t Worry Darling is a psychological thriller set in 1950s in an isolated, utopian community in the California desert.
It follows the relationship between an unhappy housewife and her husband.
Chris Pine and Wilde, who made her directorial debut last year with Booksmart, also star in the film from screenwriter Katie Silberman.
Styles made his acting debut in Christopher Nolan’s Oscar-winning war film Dunkirk in 2017 and reportedly auditioned for the role of Elvis Presley in Baz Luhrmann’s upcoming biopic.
Last year, it emerged that he turned down the role of Prince Eric in Disney’s live-action reimagining of The Little Mermaid, with the part eventually going to US actor Austin Butler.
He also appeared as himself in the teen sitcom iCarly in 2012 and in a number of tour films during his time in One Direction and as a solo artist.
Styles’ self-titled debut album arrived in 2017 to critical acclaim and topped the charts on both sides of the Atlantic.
His second effort, Fine Line, was released in December and was another success thanks to singles including Lights Up, Adore You and Watermelon Sugar.