Here it is at Gloucester in December 1968 http://www.railphotoprints.co.uk/index/detail/6674/D6331-Gloucester-1268-RPPS519.jpg.html .
As for headcodes, I suggest the first character should be a 2 if you want to use your loco on passenger workings or a 6 if you are using it on freight.
The second character could be A for locos based in the London area, B for those from Bristol and C for Plymouth. You could also opt for Z if you want to use the loco on unusual workings.
The last two characters don't matter as much. One option is to set them to the last two numbers of the loco's identity. Another, for DCC users, is to use them to indicate the chip's address code. However, any two numbers will do.
As far as D6331 is concerned, in its Gloucester days, 6B31 or 6Z31 would not look out of place. In the photo above it has 6Z39 which fits in with my theory.
Geoff Endacott