I don't believe it is possible to implement your literal request. While you can make an UpSet definition for Head:
Unprotect[Ket];
Head[Ket[_]] ^:= Bob
Head[Ket[Subscript[x, B]]] ^:= BobKet
Head[Ket[Subscript[x, A]]] ^:= AliceKet
Head[Ket[Subscript[x, B]]]
BobKet
Since Head is not actually used by the pattern matcher this does not produce your desired behavior:
f[_BobKet] := "hit!"
f[Ket[Subscript[x, B]]]
f[Ket[Subscript[x, B]]]
(I don't actually have Ket in version 7, but I see no reason for this not to work unless Ket is atomic.)
However, I can see no need for this behavior. Instead you should simply use a pattern that matches what you want it to match. You can assign patterns to global Symbols to use them easily, if that is your concern:
bob = HoldPattern @ Ket[Subscript[x, B]];
alice = HoldPattern @ Ket[Subscript[x, A]];
f[x : bob, y : alice] := {"it worked!", x, y}
f[Ket[Subscript[x, B]], Ket[Subscript[x, A]]]
{"it worked!", Ket[Subscript[x, B]], Ket[Subscript[x, A]]}
You can even use named patterns within a pattern, e.g.:
bob = HoldPattern @ Ket[Subscript[u_, B]];
alice = HoldPattern @ Ket[Subscript[v_, A]];
f[x : bob, y : alice] := {u, v}
f[Ket[Subscript[foo, B]], Ket[Subscript[bar, A]]]
{foo, bar}
I hope this helps you implement what you need.
Applyis usually used to change the head of an expression. – Mike Honeychurch Jan 28 '14 at 05:32Clear[bob]; r=1; r[[0]]=bobyou'll get an error. Butr = Sin[x]; r[[0]]=bobworks. NowHead[r]returnsbob. I think playing games with Heads to do what is asked here is the wrong way to go about writing a program. – Nasser Jan 28 '14 at 05:37