The 22-year old Ghanaian international had helped Stuttgart win promotion following his move from AIK Stockholm after the 2016 Swedish season.
Ofori, who played four 2018 World Cup qualifiers for Ghana, had spent four seasons with AIK.
"I'm really excited to bring in Ebenezer," said NYCFC coach Patrick Vieira.
"He's a young player who is looking to improve, he is really dynamic and can cover ground. He's really aggressive, but he's good with the ball, too. I'm really pleased that we managed to bring him to the football club."
Ofori, who was named the best midfielder in the Swedish Allsvenskan in 2015, will give NYCFC competition in central midfield, where Alex Ring held down the starting spot in 2017.
Ofori becomes the second Ghanaian to join the NYCFC ranks with midfielder Kwame Awuah already on their books.