How can I add a CSS class to a View Field programmatically?
You can add any css class, HTML tag to any field through views admin UI, why don't you add the class from there?



UPDATE

Because you need add the css class based on some condition, you have to use the following preprocess function. your code is going to be some thing like this (maybe a few modification will be needed )

function mytheme_preprocess_views_view_field(&amp;$vars){
     $view = $vars['view'];
    if($YOUR_CUSTOM_CONDITION == TRUE &amp;&amp; $view-&gt;name == VIEW_NAME)
           $vars['classes_array'] = 'my-conditionally-added-class';
}


because you output the content on views you have to use mytheme_preprocess_views_view_field function.

For more information visit Themeing Views field output with Preprocess function.