I've seen Shanks has a scar on his eyes because of Teach, since Luffy was just a kid, meaning that Ace was not a pirate at that time. Does that mean that Teach had a bad nature at the beginning? Because I think it was stated that blackbeard was a nice person until he saw the darkness devil fruit.
Marshall D. Teech (Aka Blackbeard) was always a twisted and very calculating person, right from the start. He just never really showed his true personality to the rest of his crewmates, until he found the fruit he was looking for; he said so himself during his battle with Ace.
During Shanks conversation with Whitebeard, Shanks told Whitebeard the real truth about Blackbeard, when he stated that: "Blackbeard was quietly waiting for a chance. He didn't take the title of commander to be renowned, but rather to conceal himself."
Since Shanks and Whitebeard were on good terms, Shanks would most likely have visited Whitebeard a couple times previously, and apparently, during one of those visits, Blackbeard was able to catch Shanks off guard (which is still surprising, considering how adept Shanks is at Haki) and injured him.
I will answer the question on the title, "When did Shanks get scarred by Blackbeard?"
Consider the following facts:
Shanks did not have the scar when Roger's crew fought with Shiki. That was 27 yrs before the current time line (Let's call this BCT).
According to Shirohige, his and Roger's crew fought many times in the past. This was 25 or more years BCT.
Teach was with Shirohige's crew for decades.
By order of Roger, his crew was disbanded around 25 yrs BCT.
The left side of Shanks' face was not shown in the flashback of Roger's execution. That was 24 yrs BCT.
According to Yassop, Shanks did not have a pirate flag when he was recruited. That was 22 yrs BCT.
Shanks had the scar in the flashbacks at Fusha Village when Luffy was a kid. That was 13 yrs BCT.
Based on the above facts, we can assume the following:
a. Shanks got the scar sometime after the fight with Shiki (27 yrs BCT).
b. Oda sensei hid the left side of Shanks' face on purpose in the scenes of Roger's execution. The reason for this may be revealed later.
c. We can assume that pirate crews do not just easily change flags. So it is not logical to assume that Shanks had a different flag (without the scar) to his current one. Therefore his flag has always been the same.
Bonus info: Not really connected to the scar, but would like to share that since Shanks did not have a pirate flag 22 yrs BCT, it is logical to assume that he did not yet have his own crew at the time. Meaning, Yassop may have been his first nakama.
Conclusion: Shanks probably got the scar from Teach sometime between 27 yrs and 22 yrs BCT. It was most likely when he was still an apprentice at Roger's ship in one of their many encounters with Shirohige's crew.