"Where were you yesterday afternoon?"
"了" isn't used after "在" because "在" is a "to be" verb, only with respect to where something is located. "在" is used to indicate the state of being located somewhere. The action of a "to be" verb is ongoing and as such, cannot be completed since it's generally used as a passive voice verb. When deciding when to use "了", when indicating the completion of a verb, make sure the verb is an active voice verb.
You are correct in that one of the uses of 了 is to show a change in state, like the example you mentioned. To expand on 了 being kind of like a past tense marker (although that's not what it's for), 了 can also be used after a verb or adjective to indicate completion.
Could it be you were confusing 'afternoon' with 'morning'? Morning can be '早上' & '上午, but I only no afternoon as '下午'
Otherwise I think it may be the placement of '上'.
I have no idea if it is correct but it helps me remember if I think that '上‘ after something indicates 'during' but '上' at the begining is 'before'.
So with '午' (noon) 上午 is before noon i.e. morning'. With ’晚‘ (evening/night) and '早' (morning) adding '上‘ makes ’晚上‘ (during the?) evening/night and '早上': (during the?) day.