It's often a bit easier to debug someone else's code when you can actually see it :-)
A context is not assigned by assigning the name of the context as you've done here. You have to use the actual context object associated with that name.
Here's a small example which creates a test item in the Miscellaneous project with context Home (using the parse tasks verb), then finds the context Office and assigns it to the test item instead of Home.
Code:
tell application "OmniFocus"
tell front document
set mytask to first item of (parse tasks with transport text "test item > Miscellaneous @Home")
set mycontext to first flattened context where name is "Office"
set context of mytask to mycontext
end tell
end tell
The "flattened context" bit allows you to find a matching context even if it is nested inside another ("Errands : Office") whereas the same statement without the "flattened" adjective would only find items at the top level ("Office").