Both sentences are correct.
If you are now an adult, whichever sentences you use, it's right.
As a teenager, I was painfully shy
Because you use "was", people understand that you are describing the moment you were a teenager.
When I was a teenager, I was painfully shy
This is also correct. You were also describing the moment or period when you were a teenager.
The small difference is probably this:
"As" is a preposition, so after "as" you use a noun.
But "when" is a relative pronoun, which means you use a clause (a complete sentence with subject verb and so on)
Considering this, both of your sentences are grammaticaly correct đ