For completion sake, I decided to post the bit to create a new task in a new or existing project in OmniFocus through AppleScript. I have this in my script that creates tasks from my mail.
If you know a bit of AppleScript, this should help out. If I have the energy, I might post the entire script later and explain the parts.
In this case, it took longest to figure out the following part:
tell MyProject
set theTask to make new task with properties¬
{name:MyTaskTopic, context:MyContext, note:ThisNote}
end tell
Apparently, when creating a new task you have to tell the project. If you want to set the context, you instead tell the task to set its context property to something.
This does make sense, in the way that you always tell the containing item to do something.