I thought that the Stark name went back to Middle Ages, but then in Agent Carter, Tony's father says that his father was poor and a nobody.
What's the truth?
The two are NOT mutually exclusive. However, as of "Age of Ultron" there is zero evidence in the Marvel Cinematic Universe (MCU) that the Stark name goes back to the Middle Ages. In fact, other than the one line you mention, we have no information whatsoever regarding the Stark lineage.
The Marvel Cinematic Universe (Earth-199999) includes both Agent Carter as well as the Iron Man & Avengers movies. So far, Howard Stark's mention that his father was poor & unknown is the only information we have about generations of Starks preceding Howard and Tony.
Note: Please keep in mind that the Stark family from Game of Thrones is NOT related in any way to Tony Stark or the Marvel Cinematic Universe. Unfortunately.
Could you be thinking of Marvel 1602? This limited series takes place in Earth-311, making it an alternate continuity, but it contained versions of Marvel characters from the 1600s, including one Lord Iron, who was similar to Tony Stark. This was not intended to imply that he was an ancestor of Tony's, however; it's an alternate timeline altogether.